Asynchronous Call Pattern Problem #2
- From: lucius <lucius@xxxxxxxxxxxxxxxx>
- Date: Wed, 11 Jul 2007 11:12:21 -0400
My async web method does not seem to be truly asynchronous. My
webmethod is supposed to immediately return "nothing" to a calling
client while it makes its own webservice call to another remote thing.
Could someone tell me how to make this better? It seems like my
webmethod is still holding up the client while it makes its own remote
call instead of immediately returning.
public object prevstate;
public asyncstub myasyncstub;
public delegate List<BaseCommand> asyncstub( Invoker commandinvoker ,
List<BaseCommand> commandlist );
public List<BaseCommand> InvokerExec( Invoker commandinvoker ,
List<BaseCommand> commandlist )
{
using ( commandinvoker )
{
foreach ( BaseCommand command in commandlist )
{
// command has a "Do()" method that does the remote WS
call...
commandinvoker.ExecuteCommand( command );
// this is where the present web service hangs until the
remote web service completes
}
}
return commandlist;
}
public class invokerexecstate
{
public object prevstate;
public asyncstub myasyncstub;
}
[WebMethod]
public IAsyncResult BeginReq( string requestthing , AsyncCallback
asyncCallBack , object memstore )
{
List<BaseCommand> wantedCommands = new List<BaseCommand>();
MyCommand commandinstance = new MyCommand(requestthing);
wantedCommands.Add( commandinstance );
Invoker commandinvoker = new Invoker();
myasyncstub = new asyncstub( InvokerExec );
invokerexecstate localstate = new invokerexecstate();
localstate.prevstate = memstore;
localstate.myasyncstub = myasyncstub;
return myasyncstub.BeginInvoke( commandinvoker ,
wantedCommands , asyncCallBack , localstate );
}
[WebMethod]
public void EndReq( IAsyncResult completedResult )
{
invokerexecstate localstate =
(invokerexecstate)completedResult.AsyncState;
List<BaseCommand> completedCommands =
(List<BaseCommand>)localstate.myasyncstub.EndInvoke( completedResult
);
}
.
- Follow-Ups:
- Re: Asynchronous Call Pattern Problem #2
- From: John Saunders [MVP]
- Re: Asynchronous Call Pattern Problem #2
- Prev by Date: RE: Newbie, VIN Number decoder help
- Next by Date: Re: Asynchronous Call Pattern Problem #2
- Previous by thread: RE: Newbie, VIN Number decoder help
- Next by thread: Re: Asynchronous Call Pattern Problem #2
- Index(es):
Loading