Is it ok to run another thread inside the page then come back

C

charles

I used a web service (or dll) to create a socket/send some data in a
thread within a function in a page. After this operation, the
operation in this page continues. This approach works when the page
starts. But it often fails after running this thread a few times. The
error I got is as follows:

Server Application Unavailable
The web application you are attempting to access on this web server is
currently unavailable. Please hit the "Refresh" button in your web
browser to retry your request.

Administrator Note: An error message detailing the cause of this
specific request failure can be found in the application event log of
the web server. Please review this log entry to discover what caused
this error to occur.

==========================
The error message in the event log is "aspnet_wp.exe (PID: 3960)
stopped unexpectedly".

I doubt that this was due to the statelessness of the HTTP protocol,
since this will not happen in a desktop application. Am I right?

In order to make this operation more reliable, can I use Session
variable or Viewstate to save something before call this thread then
recover afterwards? I did try once but seems no effect. Please help.
Thank you for your time.
 
J

John Saunders

charles said:
I used a web service (or dll) to create a socket/send some data in a
thread within a function in a page.

This is almost certainly a mistake, since you don't appear to understand the
ASP.NET execution model.

Any thread that you create during the execution of a page may possibly
continue execution after the end of the request that created the page. If
you don't know what you're doing, you're almost certainly going to see some
interesting failures.

I suggest you see the article in this month's MSDN magazine on asynchronous
execution.

John
 
R

Ray

To access web services async, it's best to use the Begin*
End* methods in the proxy, ie use asychronous calls instead
of creating your own threads and sockets.
 
C

charles

To access web services async, it's best to use the Begin*
End* methods in the proxy, ie use asychronous calls instead
of creating your own threads and sockets.


Thank you, Ray. I am very interested in your suggestion. Would you
please talk in more details? How to use these methods to communicate
with outside programs?

Regards,

Charles
2/22
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top