473,396 Members | 2,033 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,396 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 2000
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.