Callback Question : Static Methods

G

Guest

Hi
I have a quick question regarding static methods as part of a callback mechanism ( with particular reference to a web service, although it is not a web service question ). Basically I have an asp.net form which makes a call to a web service asynchronously ( below ). My prroblem is that in order for the processing to occur asynchronously I have to create a static method to pass to the asynch call. The results are then available in the method once processing has completed. I need then to get the value from the static method to a label on the asp.net. Given that the static method is part of the class and the lable object is part of an instance of the class I have an issue. Can someone help me resolve this please

public static void go(String CustId, string username, string password)

SecurityServiceWse wse=new SecurityServiceWse();
UsernameToken tkn = new UsernameToken(username, password,PasswordOption.SendHashed)
wse.RequestSoapContext.Security.Tokens.Add (tkn)

//Instantiate an AsyncCallback delegate to use as a paramete
//in the Begin method
AsyncCallback cb = new AsyncCallback(ProcessAsyncRequest.SecurityCallBack)

tr

// Begin the Async call to Web Service, passing in ou
// AsyncCalback delegate and a referenc
// to our instance of SecurityService
IAsyncResult ar = wse.BeginCustOrderHist(CustId, cb, wse)



catch(Exception ex

// Do something her




public static void SecurityCallBack(IAsyncResult ar


tr

SecurityServiceWse wse =(SecurityServiceWse)ar.AsyncState

string results

results=wse.EndCustOrderHist(ar)


catch(Exception ex

// do Somethin
}
}
 
G

Guest

Have the static method update a static field with the result and access that static field with your instance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top