calling methods asynchronous in Windows Service

Hi,

if you are looking asynchronous method call to use in Windows Service .You are correct way.Asynchronous methods call is useful in windows service.

First of all create delegate;

public delegate void OnStartDelegate();

secondly create asynchronous call method;
private void OnStartCallback(IAsyncResult ar)
{
((OnStartDelegate)ar.AsyncState).EndInvoke(ar);
}

then use them in Start (or stop or anywhere you want) method like;

OnStartDelegate OnStartDelegateInst;
OnStartDelegateInst = new OnStartDelegate(OnStartAsynch);
OnStartDelegateInst.BeginInvoke(OnStartCallback, OnStartDelegateInst);


best wishes...
P.S:Please do not hesitate to share your comments.

Comments

Popular posts from this blog

Complex Query in QueryExpression in Microsoft CRM 2011

Exception caught instantiating TERADATA report server extension SQL Reporting Services

Microsoft Power Apps Portal integration with Dynamics 365 CE On-Premise - Step By Step Guide