G
Guest
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 ProcessMessageXML3AsyncStub(string asMessage)
public class MyStat
public object previousState
public ProcessMessageXML3AsyncStub asyncStub
[WebMethod
public IAsyncResult BeginProcessMessageXML3(string asMessage,AsyncCallback cb, object s
ProcessMessageXML3AsyncStub stub = new ProcessMessageXML3AsyncStub(ProcessMessageXML3)
MyState ms = new MyState()
ms.previousState = s
ms.asyncStub = stub
return stub.BeginInvoke(asMessage, cb, ms)
[WebMethod
public string EndProcessMessageXML3(IAsyncResult call
MyState ms = (MyState)call.AsyncState
return ms.asyncStub.EndInvoke(call)
public string ProcessMessageXML3(string asMessage
// Go to database and fill datatabl
OleDbConnection dbconn = new OleDbConnection("Provider=MSDAORA.1;User ID=SQL;Password=SQL;Data Source=TestDB")
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Table1", dbconn)
DataTable dt = new DataTable()
da.Fill(dt)
this.dt = dt
if(dt.Rows.Count > 100
Thread newThread = new Thread(new ThreadStart(this.CreateMoreThreads))
newThread.Start()
MemoryStream ms = CreateStream(this.dt, 0, 100)
// Do some more IO stuf
..
return "something"
private void CreateMoreThreads(
// Create even more threads depending on the number of records returne
// and do more IO stuf
Client sid
----------
private void button2_Click(object sender, System.EventArgs e
this.webservice1 = new localhost.Service1()
this.ds = new DataSet()
AsyncCallback callback = new AsyncCallback(this.ServiceCallback)
this.webservice1.BeginProcessMessageXML3(textBox4.Text, callback, null);
private void ServiceCallback(IAsyncResult result
localhost.Service1 ws = new localhost.Service1()
string s1 = ws.EndProcessMessageXML3(result)
object[] args = {s1}
this.Invoke(new ProcessStringDelegate(ProcessString), args)
public delegate void ProcessStringDelegate(string as1)
private void ProcessString(string as1
// Process the string her
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 ProcessMessageXML3AsyncStub(string asMessage)
public class MyStat
public object previousState
public ProcessMessageXML3AsyncStub asyncStub
[WebMethod
public IAsyncResult BeginProcessMessageXML3(string asMessage,AsyncCallback cb, object s
ProcessMessageXML3AsyncStub stub = new ProcessMessageXML3AsyncStub(ProcessMessageXML3)
MyState ms = new MyState()
ms.previousState = s
ms.asyncStub = stub
return stub.BeginInvoke(asMessage, cb, ms)
[WebMethod
public string EndProcessMessageXML3(IAsyncResult call
MyState ms = (MyState)call.AsyncState
return ms.asyncStub.EndInvoke(call)
public string ProcessMessageXML3(string asMessage
// Go to database and fill datatabl
OleDbConnection dbconn = new OleDbConnection("Provider=MSDAORA.1;User ID=SQL;Password=SQL;Data Source=TestDB")
OleDbDataAdapter da = new OleDbDataAdapter("SELECT * FROM Table1", dbconn)
DataTable dt = new DataTable()
da.Fill(dt)
this.dt = dt
if(dt.Rows.Count > 100
Thread newThread = new Thread(new ThreadStart(this.CreateMoreThreads))
newThread.Start()
MemoryStream ms = CreateStream(this.dt, 0, 100)
// Do some more IO stuf
..
return "something"
private void CreateMoreThreads(
// Create even more threads depending on the number of records returne
// and do more IO stuf
Client sid
----------
private void button2_Click(object sender, System.EventArgs e
this.webservice1 = new localhost.Service1()
this.ds = new DataSet()
AsyncCallback callback = new AsyncCallback(this.ServiceCallback)
this.webservice1.BeginProcessMessageXML3(textBox4.Text, callback, null);
private void ServiceCallback(IAsyncResult result
localhost.Service1 ws = new localhost.Service1()
string s1 = ws.EndProcessMessageXML3(result)
object[] args = {s1}
this.Invoke(new ProcessStringDelegate(ProcessString), args)
public delegate void ProcessStringDelegate(string as1)
private void ProcessString(string as1
// Process the string her