473,396 Members | 1,590 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.

Webservice with asynchronous call

Hello group,

I'm trying to develop a proof of concept webservice which asynchronously
calls a function in a DLL. The function raises an event when it is finished,
and works when used as part of a windows form. When I try to hook up the
webservice to the event and call the WS, the CPU goes to 100% and I have to
restart the WWW service.

Does anyone have an idea as to how this can be done ... and if not,
directions to a tall bridge would come in handy.

Thanks in advance,

--
Tim Gallivan
I know I'm a great teacher because when I give a lesson, the person never
comes back.
Nov 21 '05 #1
4 3288
can you describe the flow a bit more?
The webservice - it is an ASMX?
and within the logic behind that ASMX, you do a BeginInvoke() on a delegate
that references your external DLL?
And then you return from the webmethod call. Is that right?

Or,
within the ASMX, you do BeginInvoke() on the delegate (eventually getting to
your external DLL) and then... what?

"Tim Gallivan" <no**********************@edu.gov.on.ca> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
Hello group,

I'm trying to develop a proof of concept webservice which asynchronously
calls a function in a DLL. The function raises an event when it is finished, and works when used as part of a windows form. When I try to hook up the
webservice to the event and call the WS, the CPU goes to 100% and I have to restart the WWW service.

Does anyone have an idea as to how this can be done ... and if not,
directions to a tall bridge would come in handy.

Thanks in advance,

--
Tim Gallivan
I know I'm a great teacher because when I give a lesson, the person never
comes back.

Nov 21 '05 #2
Dino,

Thanks for responding.
Yes the webservice is an ASMX. The webservice needs to return a dataset
(which is returned by the call to the DLL in ClassA). I haven't been able to
figure out how to do it. I haven't been using BeginInvoke because I don't
know how to ... I have been using BeginDoAsyncTest and EndDoAsyncTest in my
client.

Any help would be greatly appreciated, source code is below. Thanks in
advance, Tim

private DataSet dsRR;

[WebMethod]
public DataSet DoAsyncTest(String sHost)
{
ClassA rr = new ClassA(sHost);
rr.ClassAComplete += new ClassA.ClassAEventHandler(TextHandler);
rr.Start();

while(dsRR.Tables.Count == 0)
{
System.Threading.Thread.Sleep(0);
}
return dsRR;
}

private void TextHandler(object sender, RemoteRR.ClassAEventArgs e)
{
DataSet dsResults = new DataSet();

DataTable dtResults = dsResults.Tables.Add("Results");
DataColumn dc = dtResults.Columns.Add("CallId",typeof(Int64));
dtResults.Columns.Add("Error",typeof(Int16));
dtResults.Columns.Add("Results",typeof(String));
dtResults.Columns.Add("HTML",typeof(String));
dtResults.Columns.Add("Error",typeof(String));

DataRow dr = dtResults.NewRow();
dr["CallId"] = 1;
dr["Error"] = 0;
dr["Results"] = e.TimeToResponse.ToString()+" "+e.TimeToFinish.ToString();
dr["HTML"] = e.PageHTML.ToString();
dr["Error"] = e.ErrorMessage.ToString();
dtResults.Rows.Add(dr);
dtResults.AcceptChanges();

dsRR = dsResults.Copy();
}

--
Tim Gallivan
I know I'm a great teacher because when I give a lesson, the person never
comes back.

"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:eS**************@TK2MSFTNGP12.phx.gbl...
can you describe the flow a bit more?
The webservice - it is an ASMX?
and within the logic behind that ASMX, you do a BeginInvoke() on a delegate that references your external DLL?
And then you return from the webmethod call. Is that right?

Or,
within the ASMX, you do BeginInvoke() on the delegate (eventually getting to your external DLL) and then... what?

"Tim Gallivan" <no**********************@edu.gov.on.ca> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
Hello group,

I'm trying to develop a proof of concept webservice which asynchronously
calls a function in a DLL. The function raises an event when it is

finished,
and works when used as part of a windows form. When I try to hook up the
webservice to the event and call the WS, the CPU goes to 100% and I have

to
restart the WWW service.

Does anyone have an idea as to how this can be done ... and if not,
directions to a tall bridge would come in handy.

Thanks in advance,

--
Tim Gallivan
I know I'm a great teacher because when I give a lesson, the person never comes back.


Nov 21 '05 #3
it sure looks like you have a tight loop in the webservice, waiting for a
response from the DLL.
Rather than loop this way, I would look into WaitHandle and the WaitOne()
call.

For example, this page:
http://msdn.microsoft.com/library/en...itOneTopic.asp

....shows how to queue an item to the worker thread pool. You can do this
within the ASMX webmethod.

You may already have support for this in ClassA, I cannot tell.
If you can get a WaitHandle from the ClassA, then just call WaitOne() on
that. (in this case You don't need to use the CLR threadpool. )

-D
"Tim Gallivan" <no**********************@edu.gov.on.ca> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
Dino,

Thanks for responding.
Yes the webservice is an ASMX. The webservice needs to return a dataset
(which is returned by the call to the DLL in ClassA). I haven't been able to figure out how to do it. I haven't been using BeginInvoke because I don't
know how to ... I have been using BeginDoAsyncTest and EndDoAsyncTest in my client.

Any help would be greatly appreciated, source code is below. Thanks in
advance, Tim

private DataSet dsRR;

[WebMethod]
public DataSet DoAsyncTest(String sHost)
{
ClassA rr = new ClassA(sHost);
rr.ClassAComplete += new ClassA.ClassAEventHandler(TextHandler);
rr.Start();

while(dsRR.Tables.Count == 0)
{
System.Threading.Thread.Sleep(0);
}
return dsRR;
}

private void TextHandler(object sender, RemoteRR.ClassAEventArgs e)
{
DataSet dsResults = new DataSet();

DataTable dtResults = dsResults.Tables.Add("Results");
DataColumn dc = dtResults.Columns.Add("CallId",typeof(Int64));
dtResults.Columns.Add("Error",typeof(Int16));
dtResults.Columns.Add("Results",typeof(String));
dtResults.Columns.Add("HTML",typeof(String));
dtResults.Columns.Add("Error",typeof(String));

DataRow dr = dtResults.NewRow();
dr["CallId"] = 1;
dr["Error"] = 0;
dr["Results"] = e.TimeToResponse.ToString()+" "+e.TimeToFinish.ToString(); dr["HTML"] = e.PageHTML.ToString();
dr["Error"] = e.ErrorMessage.ToString();
dtResults.Rows.Add(dr);
dtResults.AcceptChanges();

dsRR = dsResults.Copy();
}

--
Tim Gallivan
I know I'm a great teacher because when I give a lesson, the person never
comes back.

"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:eS**************@TK2MSFTNGP12.phx.gbl...
can you describe the flow a bit more?
The webservice - it is an ASMX?
and within the logic behind that ASMX, you do a BeginInvoke() on a delegate
that references your external DLL?
And then you return from the webmethod call. Is that right?

Or,
within the ASMX, you do BeginInvoke() on the delegate (eventually getting to
your external DLL) and then... what?

"Tim Gallivan" <no**********************@edu.gov.on.ca> wrote in message
news:Oe**************@TK2MSFTNGP11.phx.gbl...
Hello group,

I'm trying to develop a proof of concept webservice which asynchronously calls a function in a DLL. The function raises an event when it is

finished,
and works when used as part of a windows form. When I try to hook up the webservice to the event and call the WS, the CPU goes to 100% and I
have to
restart the WWW service.

Does anyone have an idea as to how this can be done ... and if not,
directions to a tall bridge would come in handy.

Thanks in advance,

--
Tim Gallivan
I know I'm a great teacher because when I give a lesson, the person

never comes back.



Nov 21 '05 #4
I'm assuming a "tight loop" is a BAD thing. I'll try it your way, Dino.

Thanks for the quick reply,
--
Tim Gallivan
I know I'm a great teacher because when I give a lesson, the person never
comes back.

"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:uc**************@TK2MSFTNGP12.phx.gbl...
it sure looks like you have a tight loop in the webservice, waiting for a
response from the DLL.
Rather than loop this way, I would look into WaitHandle and the WaitOne()
call.

For example, this page:
http://msdn.microsoft.com/library/en...itOneTopic.asp
...shows how to queue an item to the worker thread pool. You can do this
within the ASMX webmethod.

You may already have support for this in ClassA, I cannot tell.
If you can get a WaitHandle from the ClassA, then just call WaitOne() on
that. (in this case You don't need to use the CLR threadpool. )

-D
"Tim Gallivan" <no**********************@edu.gov.on.ca> wrote in message
news:Ob**************@TK2MSFTNGP12.phx.gbl...
Dino,

Thanks for responding.
Yes the webservice is an ASMX. The webservice needs to return a dataset
(which is returned by the call to the DLL in ClassA). I haven't been able
to
figure out how to do it. I haven't been using BeginInvoke because I don't know how to ... I have been using BeginDoAsyncTest and EndDoAsyncTest in

my
client.

Any help would be greatly appreciated, source code is below. Thanks in
advance, Tim

private DataSet dsRR;

[WebMethod]
public DataSet DoAsyncTest(String sHost)
{
ClassA rr = new ClassA(sHost);
rr.ClassAComplete += new ClassA.ClassAEventHandler(TextHandler);
rr.Start();

while(dsRR.Tables.Count == 0)
{
System.Threading.Thread.Sleep(0);
}
return dsRR;
}

private void TextHandler(object sender, RemoteRR.ClassAEventArgs e)
{
DataSet dsResults = new DataSet();

DataTable dtResults = dsResults.Tables.Add("Results");
DataColumn dc = dtResults.Columns.Add("CallId",typeof(Int64));
dtResults.Columns.Add("Error",typeof(Int16));
dtResults.Columns.Add("Results",typeof(String));
dtResults.Columns.Add("HTML",typeof(String));
dtResults.Columns.Add("Error",typeof(String));

DataRow dr = dtResults.NewRow();
dr["CallId"] = 1;
dr["Error"] = 0;
dr["Results"] = e.TimeToResponse.ToString()+"

"+e.TimeToFinish.ToString();
dr["HTML"] = e.PageHTML.ToString();
dr["Error"] = e.ErrorMessage.ToString();
dtResults.Rows.Add(dr);
dtResults.AcceptChanges();

dsRR = dsResults.Copy();
}

--
Tim Gallivan
I know I'm a great teacher because when I give a lesson, the person never comes back.

"Dino Chiesa [Microsoft]" <di****@online.microsoft.com> wrote in message
news:eS**************@TK2MSFTNGP12.phx.gbl...
can you describe the flow a bit more?
The webservice - it is an ASMX?
and within the logic behind that ASMX, you do a BeginInvoke() on a

delegate
that references your external DLL?
And then you return from the webmethod call. Is that right?

Or,
within the ASMX, you do BeginInvoke() on the delegate (eventually

getting
to
your external DLL) and then... what?

"Tim Gallivan" <no**********************@edu.gov.on.ca> wrote in message news:Oe**************@TK2MSFTNGP11.phx.gbl...
> Hello group,
>
> I'm trying to develop a proof of concept webservice which

asynchronously > calls a function in a DLL. The function raises an event when it is
finished,
> and works when used as part of a windows form. When I try to hook up the > webservice to the event and call the WS, the CPU goes to 100% and I have to
> restart the WWW service.
>
> Does anyone have an idea as to how this can be done ... and if not,
> directions to a tall bridge would come in handy.
>
> Thanks in advance,
>
> --
> Tim Gallivan
> I know I'm a great teacher because when I give a lesson, the person

never
> comes back.
>
>



Nov 21 '05 #5

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

Similar topics

17
by: Patrick | last post by:
I am almost certain that I could use HTTP Post/Get to submit XML Web Service call (over SSL as well, if using Version 3 of MSXML2) from an ASP Application? However, would I only be able to call...
3
by: Grigs | last post by:
Hello, I have an ASP.Net webform that shows numerous attributes of parts we sell. There is one portion of the form that I have the user click a button to get the information for. I did this for...
4
by: Bamse | last post by:
Hi all, The problem is as follows: I need to authorize a user: through a WS; if a setting is on, the webservice will look in the local "database", if the setting is off it will connect to the...
0
by: Jens Weibler | last post by:
Hi, I'm trying to call a webservice asynchronous and works. But if I enter a wrong proxy webservice.Proxy = new WebProxy("b"); I won't get a callback with an async call like...
0
by: Raymondr | last post by:
Hi, First a brief description of out application: We have a webapplication which calls a couple of webservices during one request (postback). These calls to the webservices are made concurrent...
0
by: Paul Hadfield | last post by:
Hi, From reading various articles on scalability issues, I understand that there is only a finite number of ASP.NET worker threads and any long running task within ASP.NET should be fired off on...
2
by: =?Utf-8?B?S2FseWFu?= | last post by:
Hi, I have to make multiple calls (about 400K) to a webservice which returns a string. And currently it takes about a week to make all the calls. Instead of waiting for the webservice result ...
0
by: sirmoreno | last post by:
Hi, In my web site I have some long tasks that I want to call without delaying the page rendering - without making the thread that handels the page request wait for the long task to end. I...
1
by: dearprasan | last post by:
Hi, I am making a call to a asynchronous call to a webservice using callback. Before I make the asynchronous call, I am allowed to make the following cast: IHTMLDocument2 doc = (IHTMLDocument2)...
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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,...

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.