{
delegate void SimpleAsyncCallback (SimpleAsyncResult result);
- delegate bool SimpleAsyncFunc (SimpleAsyncResult result);
-
class SimpleAsyncResult : IAsyncResult
{
ManualResetEvent handle;
bool synch;
bool isCompleted;
- SimpleAsyncCallback cb;
+ readonly SimpleAsyncCallback cb;
object state;
bool callbackDone;
Exception exc;
};
}
- public static void Run (SimpleAsyncFunc func, SimpleAsyncCallback callback)
+ public static void Run (Func<SimpleAsyncResult, bool> func, SimpleAsyncCallback callback)
{
var result = new SimpleAsyncResult (callback);
try {
}
}
- public static void RunWithLock (object locker, SimpleAsyncFunc func, SimpleAsyncCallback callback)
+ public static void RunWithLock (object locker, Func<SimpleAsyncResult, bool> func, SimpleAsyncCallback callback)
{
Run (inner => {
bool running = func (inner);
DoCallback_private ();
}
- protected void SetCompleted_internal (bool synch, Exception e)
+ void SetCompleted_internal (bool synch, Exception e)
{
this.synch = synch;
exc = e;
protected void SetCompleted_internal (bool synch)
{
- this.synch = synch;
- exc = null;
- lock (locker) {
- isCompleted = true;
- if (handle != null)
- handle.Set ();
- }
+ SetCompleted_internal (synch, null);
}
void DoCallback_private ()