Bagikan melalui


NativeActivity<TResult>.Execute(NativeActivityContext) Metode

Definisi

Saat diimplementasikan di kelas turunan, menjalankan logika eksekusi aktivitas.

protected:
 abstract void Execute(System::Activities::NativeActivityContext ^ context);
protected abstract void Execute (System.Activities.NativeActivityContext context);
abstract member Execute : System.Activities.NativeActivityContext -> unit
Protected MustOverride Sub Execute (context As NativeActivityContext)

Parameter

context
NativeActivityContext

Konteks eksekusi tempat aktivitas dijalankan.

Contoh

Sampel kode berikut menunjukkan menggunakan Jalankan di kelas yang mewarisi dari NativeActivity<TResult>. Contoh ini berasal dari sampel ParallelForEach Non-Generik .

protected override void Execute(NativeActivityContext context)
{
    IEnumerable values = this.Values.Get(context);
    if (values == null)
    {
        throw new InvalidOperationException("ParallelForEach requires a non-null Values argument.");
    }

    IEnumerator valueEnumerator = values.GetEnumerator();

    CompletionCallback onBodyComplete = new CompletionCallback(OnBodyComplete);
    while (valueEnumerator.MoveNext())
    {
        if (this.Body != null)
        {
            context.ScheduleAction(this.Body, valueEnumerator.Current, onBodyComplete);
        }
    }
    IDisposable disposable = valueEnumerator as IDisposable;
    if (disposable != null)
    {
        disposable.Dispose();
    }
}

Berlaku untuk