Converting Asynchronous Programming Model (Begin/End methods) into event-based asynchronous model?
Posted
by David
on Stack Overflow
See other posts from Stack Overflow
or by David
Published on 2009-11-09T16:52:35Z
Indexed on
2010/04/07
8:03 UTC
Read the original article
Hit count: 422
Let's say I have code that uses the Asynchronous Programming Model, i.e. it provides the following methods as a group which can be used synchronously or asynchronously:
public MethodResult Operation(<method params>);
public IAsyncResult BeginOperation(<method params>, AsyncCallback callback, object state);
public MethodResult EndOperation(IAsyncResult ar);
What I want to do is wrap this code with an additional layer that will transform it into the event-driven asynchronous model, like so:
public void OperationAsync(<method params>);
public event OperationCompletedEventHandler OperationCompleted;
public delegate void OperationCompletedEventHandler(object sender, OperationCompletedEventArgs e);
Does anyone have any guidance (or links to such guidance) on how to accomplish this?
© Stack Overflow or respective owner