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

Could not load file or assembly 'System.ServiceModel, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified at Configuration class initiation in CrmServiceHelper.cv

Exception caught instantiating TERADATA report server extension SQL Reporting Services

you face "ISV code aborted the operation" when you change status of the any record in Dynamics CRM 2013