473,326 Members | 2,104 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Asynchronous web methods

hs
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
Jul 21 '05 #1
1 1992
Hello,

Thanks for your post. I reviewed your description and web methods
client/server code carefully, and now I'd like to share the following
information with you:

1. I believe that your design is good and efficient. I noticed that you
code is based on asynchronous web methods on both client and server sides.
It also seems to me that your client program is a WinForm application, and
I believe using a delegate to call the web method is a nice approach which
will not block the message thread for the client. That is, your application
is responsive while the web method is under processing (after user clicking
Button2). On the server side, it access Oracle database which is
time-consuming.

2. >> However i dont see any improvements to the speed of my application.

One reason why the asynchronous method call enables the performance is that
we can perform several tasks simultaneously. For example, your client
application is responsive and can perform other tasks when the web method
is processing on the remote system. If your application is just idle and
waiting for the delegate to be called, there is no difference between
synchronous and asynchronous method calls in terms of performance. It's of
the same case on server side, we are able to notice the performance
increase when there are several web methods calls coming in simultaneously.

Please feel free to let me know if you have any problems or concerns.

Have a nice day! :-)

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Jul 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Julian Hershel | last post by:
Reading about asynchronous programming (ms-help://MS.NETFrameworkSDK/cpguidenf/html/cpconasynchronousdesignpatterno verview.htm) I could not clarify some doubts. Hope you can help me. 1) Are...
5
by: rgarf | last post by:
I have a C++ application that consumes a web service. I would like to call the web service asynchronously so my C++ application can do other processing in between. My proxy file does not have any...
1
by: org | last post by:
Hi, I'm developing a web service with should be used by an .NET CF2 client and an .NET 2.0 Windows client. I've tried to put all the connection logic into one class, which could be used in...
4
by: taskswap | last post by:
I have a legacy application written in C that I'm trying to convert to C#. It processes a very large amount of data from many clients (actually, upstream servers - this is a mux) simultaneously. ...
1
by: dba123 | last post by:
I need to perform Asynchronous Inserts using DAAB. So far I have a method which does an insert but how can I do this Asyncronously so that it does not affect the load on our public production...
5
by: HugeBob | last post by:
Hi All, I've got a question about Asynchronous vs Synchronous mode with the XMLHttpRequest object. What are the ramifications of using one mode vs the other? If the script uses Asynchronous...
1
by: jan.loucka | last post by:
I'm developing WinForms application in .NET 2.0 that talks to web service. The automatically generated proxy (reference class) has got methods for both synchronous and asynchronous invocations of...
1
by: jan.loucka | last post by:
I'm developing WinForms application in .NET 2.0 that talks to web service. The automatically generated proxy (reference class) has got methods for both synchronous and asynchronous invocations of...
4
by: Varangian | last post by:
Hello, the subjects says much I think. Basically I want to create my own long running tasks asynchronously. I want to have a BeginMyOwnLongTediousMethod and EndMyOwnLongTediousMethod You...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.