Posts

Showing posts with the label aynchronous method calls in Windows Service

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.