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

Assembly Microsoft.Dynamics.Service.Plugins.dll can not be loaded. Dynamics CRM 365 Engine version 9 - CRM User creation error

Exception caught instantiating TERADATA report server extension SQL Reporting Services

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