Files
dotnet-bot adf899c629 Adding System.Data..., System.ServiceModel..., and System.Web...
Adding reference source for
System.Data
System.Data.DataSetExtensions
System.Data.Entity
System.Data.Entity.Design
System.Data.Linq
System.Data.SqlXml
System.ServiceModel
System.ServiceModel.Activation
System.ServiceModel.Activities
System.ServiceModel.Channels
System.ServiceModel.Discovery
System.ServiceModel.Internals
System.ServiceModel.Routing
System.ServiceModel.WasHosting
System.ServiceModel.Web
System.Web
System.Web.ApplicationServices
System.Web.DynamicData
System.Web.Entity
System.Web.Entity.Design
System.Web.Extensions
System.Web.Mobile
System.Web.Routing
System.Web.Services
System.Xml
System.Xml.Linq
2016-05-03 00:07:37 +02:00

55 lines
1.7 KiB
C#

//-----------------------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
namespace System.Runtime
{
using System;
using System.Threading;
// An AsyncResult that schedules work for later on the IOThreadScheduler
abstract class ScheduleActionItemAsyncResult : AsyncResult
{
static Action<object> doWork = new Action<object>(DoWork);
// Implement your own constructor taking in necessary parameters
// Constructor needs to call "Schedule()" to schedule work
// Cache all parameters
// Implement OnDoWork to do work!
protected ScheduleActionItemAsyncResult(AsyncCallback callback, object state) : base(callback, state) { }
protected void Schedule()
{
ActionItem.Schedule(doWork, this);
}
static void DoWork(object state)
{
ScheduleActionItemAsyncResult thisPtr = (ScheduleActionItemAsyncResult)state;
Exception completionException = null;
try
{
thisPtr.OnDoWork();
}
catch (Exception ex)
{
if (Fx.IsFatal(ex))
{
throw;
}
completionException = ex;
}
thisPtr.Complete(false, completionException);
}
protected abstract void OnDoWork();
public static void End(IAsyncResult result)
{
AsyncResult.End<ScheduleActionItemAsyncResult>(result);
}
}
}