ASP. NET Workflow Workflow actual combat bookmarks (ii)

Source: Internet
Author: User

1. Using workflows under WinForm (Web program)

How can I make a WinForm or Web page form block waiting for a workflow to continue like a console?

2. Bookmark bookmarks

Bookmarks: and general bookmarks when reading a book, it is convenient to view the last look, the bookmark in the workflow means to pause the workflow and wait for the user to continue working in the current state.

3, the creation of bookmarks

Right-click in the project → add New item → code activity. A base class with the name bookmarkcodeactivity.cs//code activity is codeactivity

The following code is a code activity that is created

namespaceeazybpms.workflow{ Public Sealed classceshi:codeactivity {//defines an activity input parameter for a string type         Publicinargument<string> Text {Get;Set; } //If the activity returns a value, the codeactivity<tresult>//and returns the value from the Execute method.         protected Override voidExecute (Codeactivitycontext context) {//gets the run-time value of the Text input parameter            stringText = context. GetValue ( This.        Text); }    }}

But if you use it as a bookmark, you must make the following changes

1. Change the base class to change the CodeActivity to Nativeactivity
2. Overriding attribute Caninduceidle
3, modify the incoming parameters Codeactivitycontext modified to Nativeactivitycontext
4. Create bookmarks

namespaceeazybpms.workflow{//1. Change the base class to change the codeactivity to Nativeactivity//2. Overriding attribute Caninduceidle//3, modify the incoming parameters Codeactivitycontext modified to Nativeactivitycontext//4. Create Bookmarks     Public Sealed classWaitinputdataactivity<t>: nativeactivity {//This property means whether the workflow is allowed to idle/pause        protected Override BOOLCaninduceidle {Get            {                return true; }        }        //defines an activity input parameter for a string type         Publicinoutargument<string> BookmarkName {Get;Set; }  PublicOutargument<t> Outresult {Get;Set; } //If the activity returns a value, the codeactivity<tresult>//and returns the value from the Execute method.         protected Override voidExecute (Nativeactivitycontext context) {//gets the run-time value of the BookmarkName input parameter            stringText = context. GetValue ( This. BookmarkName);
Context. CreateBookMark (text,NewBookmarkcallback (mycallback)); } //Pass the data passed in as the value of the output parameter Outresult to the outside of the bookmark Private voidMycallback (nativeactivitycontext context, bookmark bookmark,Objectvalue) { vardata = value asBaseresumebookmarkvalue; if(Data! =NULL) {context. SetValue (Outresult, (T) data.value); Context. SetValue (BookmarkName, data. BookmarkName); } } }}

ASP. NET Workflow Workflow actual combat bookmarks (ii)

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.