Export (0) Print
Expand All

AsyncCodeActivity.BeginExecute Method

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.

Namespace:  System.Activities
Assembly:  System.Activities (in System.Activities.dll)

'Declaration
Protected MustOverride Function BeginExecute ( _
	context As AsyncCodeActivityContext, _
	callback As AsyncCallback, _
	state As Object _
) As IAsyncResult

Parameters

context
Type: System.Activities.AsyncCodeActivityContext
Information that defines the execution environment for the AsyncCodeActivity.
callback
Type: System.AsyncCallback
The method to be called after the asynchronous activity and completion notification have occurred.
state
Type: System.Object
An object that saves variable information for an instance of an asynchronous activity.

Return Value

Type: System.IAsyncResult
The object that saves variable information for an instance of an asynchronous activity.

The following example shows how to override the BeginExecute(AsyncCodeActivityContext, AsyncCallback, Object) 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);
}


.NET Framework

Supported in: 4

.NET Framework Client Profile

Supported in: 4

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Community Additions

ADD
Show:
© 2014 Microsoft