H
I am using the articles by Matt Powell about server side asynchronous web methods (as well as the client side article)
However i dont see any improvements to the speed of my application. I'm experiencing the
slow speed on the server side. I read that using a delegate to call an asynchronous metho
would be ineffecient and maybe causing the problem. Can someone give me some advice on wha
i can do to improve the speed without doing a complete rewrite (my code was based on a
synchronous piece)
Thank
server side cod
---------------
public delegate string ProcessMessageX ML3AsyncStub(st ring asMessage)
public class MyStat
public object previousState
public ProcessMessageX ML3AsyncStub asyncStub
[WebMethod
public IAsyncResult BeginProcessMes sageXML3(string asMessage,Async Callback cb, object s
ProcessMessageX ML3AsyncStub stub = new ProcessMessageX ML3AsyncStub(Pr ocessMessageXML 3)
MyState ms = new MyState()
ms.previousStat e = s
ms.asyncStub = stub
return stub.BeginInvok e(asMessage, cb, ms)
[WebMethod
public string EndProcessMessa geXML3(IAsyncRe sult call
MyState ms = (MyState)call.A syncState
return ms.asyncStub.En dInvoke(call)
public string ProcessMessageX ML3(string asMessage
// Go to database and fill datatabl
OleDbConnection dbconn = new OleDbConnection ("Provider=MSDA ORA.1;User ID=SQL;Password =SQL;Data Source=TestDB")
OleDbDataAdapte r da = new OleDbDataAdapte r("SELECT * FROM Table1", dbconn)
DataTable dt = new DataTable()
da.Fill(dt)
this.dt = dt
if(dt.Rows.Coun t > 100
Thread newThread = new Thread(new ThreadStart(thi s.CreateMoreThr eads))
newThread.Start ()
MemoryStream ms = CreateStream(th is.dt, 0, 100)
// Do some more IO stuf
..
return "something"
private void CreateMoreThrea ds(
// Create even more threads depending on the number of records returne
// and do more IO stuf
Client sid
----------
private void button2_Click(o bject sender, System.EventArg s e
this.webservice 1 = new localhost.Servi ce1()
this.ds = new DataSet()
AsyncCallback callback = new AsyncCallback(t his.ServiceCall back)
this.webservice 1.BeginProcessM essageXML3(text Box4.Text, callback, null);
private void ServiceCallback (IAsyncResult result
localhost.Servi ce1 ws = new localhost.Servi ce1()
string s1 = ws.EndProcessMe ssageXML3(resul t)
object[] args = {s1}
this.Invoke(new ProcessStringDe legate(ProcessS tring), args)
public delegate void ProcessStringDe legate(string as1)
private void ProcessString(s tring as1
// Process the string her