-----------------------------------------------------------

New Message on BDOTNET

-----------------------------------------------------------
From: Mrinal
Message 4 in Discussion

Hi ,   I will try to give you some example on how to go about doing this ,   
Since , you are trying to hide the asynchronous implementation from co - 
developer , so you implement the aysnc calling in a separate middle layer class 
and co - developer calls your method synchronously , now the point is till the 
execution taking place on separate thread , if you don't make it responsive , 
then it will seem to be a synchronous call to end user .   Have a look at this 
Middle Layer code :   public class MiddleLayer // Middle Layer Class { private 
WebServiceAsyncCall webServiceAsyncCall ; // Web Service Object   private int 
webServiceReturnValue ; // Web Service Return Value   
public WebApplicationAsyncMiddleLayer() 
{webServiceAsyncCall = new WebServiceAsyncCall() ;} 
 
public int CallWebWebserviceAsync(int firstValue,int secondValue) 
{ 
AsyncCallback callBack = new AsyncCallback(CallBackMethod) ; // Call Back 
Delegate 
IAsyncResult ar = 
webServiceAsyncCall.BeginHelloWorldCalculation(firstValue,secondValue,callBack,null)
 ; 
while(!ar.IsCompleted) 
{ 
// code to make things Responsive . 
// Can call a client side Javascript for the purpose  
} 
return (webServiceReturnValue) ; 
} 
public void CallBackMethod(IAsyncResult ar) 
{ 
webServiceReturnValue = webServiceAsyncCall.EndHelloWorldCalculation(ar) ; 
} 
} 
Now the co - developer with synchronously call CallWebWebserviceAsync method , 
from where things will become asynchronous , as you can see the implementation 
with AsyncCallBackDelegate , now as i have mentioned in the while loop , you 
need to implement the code to give an asynchronous / responsive touch . 
If you any doubts related to code , ping me back . 
Now your questions : 
1. By Asynchronous calling essentially you are using a separate thread for 
execution , so that's it , you need not do anything explicitly with that and in 
case way you have mentioned primary thread exits , then it is as good as your 
webpage that is doing the processing going off / server going down , so you 
can't do much in that except passing a this object while calling middle layer 
and checking it for nullability before showing the final results . 
2. Code Example shows clearly on how delegate object is created and passed 
within the layer , infact in case you want some other layer / class method 
being called then assign delegate the method in that class and you can create 
delegate object in middle layer or pass it in constructor while invoking middle 
layer , since delegate is a refernce type . 
I hope this will help you . 
any other doubt get back to me . 
regards , 
Mrinal 
 

-----------------------------------------------------------

To stop getting this e-mail, or change how often it arrives, go to your E-mail 
Settings.
http://groups.msn.com/bdotnet/_emailsettings.msnw

Need help? If you've forgotten your password, please go to Passport Member 
Services.
http://groups.msn.com/_passportredir.msnw?ppmprop=help

For other questions or feedback, go to our Contact Us page.
http://groups.msn.com/contact

If you do not want to receive future e-mail from this MSN group, or if you 
received this message by mistake, please click the "Remove" link below. On the 
pre-addressed e-mail message that opens, simply click "Send". Your e-mail 
address will be deleted from this group's mailing list.
mailto:[EMAIL PROTECTED]

Reply via email to