473,322 Members | 1,736 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,322 software developers and data experts.

Spanning thread in WS Async Call

Hi,
Here is my problem.

I am calling a web service asynchronously as follows

Registred the event handler as follows

_Data.GetDataCompleted += new MyNameSpace.GetDataCompleted
EventHandler(GetControlDataCompleted);
//Here is the call back method
void GetControlDataCompleted(object sender, GetDataCompletedEventArgs e)

{

//I get the some data from eventagrs e.

}

I want to span thread here to do some operation on the the result data and
then fill up some object. As this asyn call is on different thread ann even
if we span no of threadd, they will not executed as the calling async
thread's life cycles ends.

Please suggest me on how to go about it.

This is just to improve the preformance of the WS call as it involved lots
of operation to do on the result.

Thanls alot for your time
~Mohan
Aug 31 '07 #1
3 1483
"Mohan Babu D" <Mo********@discussions.microsoft.comwrote in message
news:D4**********************************@microsof t.com...
Hi,
Here is my problem.

I am calling a web service asynchronously as follows

Registred the event handler as follows

_Data.GetDataCompleted += new MyNameSpace.GetDataCompleted
EventHandler(GetControlDataCompleted);
//Here is the call back method
void GetControlDataCompleted(object sender, GetDataCompletedEventArgs e)

{

//I get the some data from eventagrs e.

}

I want to span thread here to do some operation on the the result data and
then fill up some object. As this asyn call is on different thread ann
even
if we span no of threadd, they will not executed as the calling async
thread's life cycles ends.
I'm sorry, I don't understand. Why don't you do your processing within the
event handler? It will be called asynchronously, on a separate thread, when
the GetData call completes.
--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer

Aug 31 '07 #2
Joh,
Thanks for the reply. You are right. The event handler will be called in a
seperate thread. But i want to process the results in this eventhandler and
to improve the performance. i wanted to have multiple threads or some other
way in this Eventhandler.
Is there any way??
~Mohan
"John Saunders [MVP]" wrote:
"Mohan Babu D" <Mo********@discussions.microsoft.comwrote in message
news:D4**********************************@microsof t.com...
Hi,
Here is my problem.

I am calling a web service asynchronously as follows

Registred the event handler as follows

_Data.GetDataCompleted += new MyNameSpace.GetDataCompleted
EventHandler(GetControlDataCompleted);
//Here is the call back method
void GetControlDataCompleted(object sender, GetDataCompletedEventArgs e)

{

//I get the some data from eventagrs e.

}

I want to span thread here to do some operation on the the result data and
then fill up some object. As this asyn call is on different thread ann
even
if we span no of threadd, they will not executed as the calling async
thread's life cycles ends.

I'm sorry, I don't understand. Why don't you do your processing within the
event handler? It will be called asynchronously, on a separate thread, when
the GetData call completes.
--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer

Aug 31 '07 #3
"Mohan Babu D" <Mo********@discussions.microsoft.comwrote in message
news:72**********************************@microsof t.com...
Joh,
Thanks for the reply. You are right. The event handler will be called in a
seperate thread. But i want to process the results in this eventhandler
and
to improve the performance. i wanted to have multiple threads or some
other
way in this Eventhandler.
Is there any way??
Certainly.

If I understand you, the issue is that, if you start more threads within the
event handler, the request will be over by the time the other threads
execute, and the state they are working on will disappear. There's an even
better question: will adding other threads improve performance at all?

The way to answer that question is to first get the code working with the
single thread within the event handler. Then measure the performance. If you
find that the performance is adequate, then stop thinking about extra
threads and proceed with the remainder of your application.

If the performance is inadequate, you need to determine whether adding
additional threads will improve the performance. Additional threads are good
for only two things: improving utilization of unused CPUs and initiating I/O
operations which can take advantage of unused I/O resources. If all of your
CPUs are nearly at 100% utilization, then adding more threads will make
things worse. If you have no disks waiting to have data written to them or
read from them, and if they're connected to IO busses which are not at
maximum utilization, then again, you don't want additional threads.

Only if you've gone through this sort of analysis (and in more detail than
I've outlined here) should you consider adding more threads.

--------------------------------------------------------------------------------
John Saunders | MVP – Windows Server System – Connected System Developer

Sep 1 '07 #4

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

Similar topics

1
by: scott ocamb | last post by:
hello I have implemented a solution using async methods. There is one async method that can be invoked multiple times, ie there are multiple async "threads" running at a time. When these...
4
by: Matthew Groch | last post by:
Hi all, I've got a server that handles a relatively high number of concurrent transactions (on the magnitude of 1000's per second). Client applications establish socket connections with the...
2
by: Tom Vandeplas | last post by:
Hi all, When using an asynchronous API call (in my case WriteFileEx) in a thread it seems to become blocking instead of non-blocking (see details below). Can somebody explain me what is...
8
by: MuZZy | last post by:
Hi, Could someone pls help me here: If i use async sockets in the separate thread like this: void ThreadFunction() { ..... 1. MySocket.BeginAccept(AsyncCallBack(OnConnectRequest),...
3
by: Giovanni Bassi | last post by:
Hello Group, I am running an operation in a different thread. There are resources that are released when the thread is done running. This is done at the end of the execution as it raises an...
4
by: Daylor | last post by:
hi. i have multi thread application in vb.net is there a way NET support, so i can mark the class , to be access only for 1 thread each time ? if there is , small sytax sample will help ...
12
by: Tomaz Koritnik | last post by:
Is it possible to asynchronously call a method from worker thread so that this method would execute in main-thread? I'm doing some work in worker thread and would like to report progress to main...
0
by: =?Utf-8?B?TW9oYW4gQmFidSBE?= | last post by:
Hi, Here is my problem. I am calling a web service asynchronously as follows Registred the event handler as follows _Data.GetDataCompleted += new MyNameSpace.GetDataCompleted...
10
by: Paul E Collins | last post by:
I want to fill an ImageList with bitmaps for a ListView from another thread, because it's a time-consuming process. I expect the ListViewItems' images to "load" one by one, as in a Web browser. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
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
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
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.