By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,595 Members | 3,721 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,595 IT Pros & Developers. It's quick & easy.

Webservice with asynchronous call

P: n/a
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
Share this Question
Share on Google+
4 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.