Szerkesztés

Megosztás a következőn keresztül:


AsyncCodeActivity.BeginExecute Method

Definition

When implemented in a derived class and using the specified execution context, callback method, and user state, enqueues an asynchronous activity in a run-time workflow.

protected:
 abstract IAsyncResult ^ BeginExecute(System::Activities::AsyncCodeActivityContext ^ context, AsyncCallback ^ callback, System::Object ^ state);
protected abstract IAsyncResult BeginExecute (System.Activities.AsyncCodeActivityContext context, AsyncCallback callback, object state);
abstract member BeginExecute : System.Activities.AsyncCodeActivityContext * AsyncCallback * obj -> IAsyncResult
Protected MustOverride Function BeginExecute (context As AsyncCodeActivityContext, callback As AsyncCallback, state As Object) As IAsyncResult

Parameters

context
AsyncCodeActivityContext

Information that defines the execution environment for the AsyncCodeActivity.

callback
AsyncCallback

The method to be called after the asynchronous activity and completion notification have occurred.

state
Object

An object that saves variable information for an instance of an asynchronous activity.

Returns

The object that saves variable information for an instance of an asynchronous activity.

Examples

The following example shows how to override the BeginExecute method in a custom activity.

protected override IAsyncResult BeginExecute(AsyncCodeActivityContext context, AsyncCallback callback, object state)
{
    string tempFileName = Path.GetTempFileName();
    Console.WriteLine("Writing to file: " + tempFileName);

    FileStream file = File.Open(tempFileName, FileMode.Create);

    context.UserState = file;

    byte[] bytes = UnicodeEncoding.Unicode.GetBytes("123456789");
    return file.BeginWrite(bytes, 0, bytes.Length, callback, state);
}

Applies to