Wf4: Custom tracking reference

Source: Internet
Author: User

In the previous articleArticle Http://www.cnblogs.com/carysun/archive/2011/01/23/WF4-ETW.htmlWe talked aboutWf4InETW Tracking reference, this is Wf4 Let's take a look at the structure of this class:

etwtrackingparticipant ipant inherited from trackingparticipant ipant class, if we want to customize our own tracking referers, we also inherit this class. We only need to rewrite the corresponding method, we will customize a trail reference by workflow information is written to the file:

Public Class Txtfiletrackingparticipant ipant:Trackingparticipant ipant

{

StringFilename ="";

Protected Override VoidTrack (TrackingrecordRecord,TimespanTimeout)

{

 

Filename =@ "C :\"+ Record. instanceid +". Txt";

Using(StreamwriterSw =File. Appendtext (filename ))

{

Sw. writeline ("---------- Begin tracking ----------");

Sw. writeline (record. tostring ());

Sw. writeline ("---------- End tracking ----------");

}

}

}

We simply design a workflow, and thenTxtfiletrackingparticipant ipantAdded to the workflow extension point,CodeAs follows:

Class Program

{

Static VoidMain (String[] ARGs)

{

// ETW tracking setup

TrackingprofileTrackingprofile =New Trackingprofile();

Trackingprofile. Queries. Add (New Workflowinstancequery

{

States = {"*"}

});

Trackingprofile. Queries. Add (New Activitystatequery

{

States = {"*"}

});

Trackingprofile. Queries. Add (New Customtrackingquery

{

Activityname ="*",

Name ="*"

});

Txtfiletrackingparticipant ipantTxtfiletrackingparticipant ipant =New Txtfiletrackingparticipant ipant();

Txtfiletrackingparticipant. trackingprofile = trackingprofile;

 

AutoreseteventAutoresetevent =New Autoresetevent(False);

WorkflowapplicationWorkflowapplication =New Workflowapplication(New Workflow1());

Workflowapplication. Completed = (ARG) =>{ autoresetevent. Set ();};

Workflowapplication. Extensions. Add (txtfiletrackingparticipant ipant );

Workflowapplication. Run ();

Autoresetevent. waitone ();

}

}

Then we run the workflow. After the workflow is complete, we will see that the tracking information has been recorded in the text file as follows:

You can record the tracing information of a workflow to the media you need in a similar way.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.