Locking/Threads

N

Norm Dotti

I have 2 forms, Form1 and Form2. Form1 contains a
Windows.Forms.Timer component that triggers at 30 second
intervals. At each 30 second interval, a synchronous
WebService (WebService1), that returns an integer, is
called. Form1 contains a button, that, when clicked,
displays Form2 modelessly (i.e. Form2.Show()). Form2
contains a button, and in it's click event a long (may
take several minutes ) SQL query is run via an
asynchronous WebService (WebService2) call. Everything
works OK until the query starts running. Approximately, 1
min and 30 seconds after the query starts running, the
WebService call in Form1's timer tick eventhandler throws
a "System.Net.WebException" w/ message "The operation has
timed-out." About 1 min. 30 secs. after that, the Async
WebMethod call in Form2 throws
a "System.InvalidOperationException" w/ message "Client
found response content type of 'text/html', but
expected 'text/xml'. ...". To correct these errors
I've: 1) tried changing the type of Timer used (b/c I
thought it might be a threading issue) - but had the same
errors, and 2) tried setting the Timeout property to
Infinity for the synchronous WebMethod call in Form1 - but
it still threw "InvalidOperationException" errors. Any
other suggestions? It appears to me that the asynchronous
WebService call is blocking the synchronous method call.
Any ideas why?
 
Y

Ying-Shen Yu[MSFT]

Hi Norm,
Threading problems are always hard to debug, but I think tracing your
program by adding Debug Output is a good way. Then you may get some more
info about your problem, such as which statement did it block, how about
the state of the two threads, and etc.
On your problem, I'm not clear about the details. But I guess it maybe
the case. When you do the synchronous WebService, the thread is blocked for
waiting data. And the WebService2 thread just want to use the main thread,
then an exception raised. However, you should first investigate this
problem further using DebugOutput.
.NET Framework comes with a Debug class in System.Diagnostics namespace.

Thanks!


Best regards,

Ying-Shen Yu [MSFT]
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security

This posting is provided "AS IS" with no warranties and confers no rights.

--------------------
| Content-Class: urn:content-classes:message
| From: "Norm Dotti" <[email protected]>
| Sender: "Norm Dotti" <[email protected]>
| Subject: Locking/Threads
| Date: Fri, 12 Sep 2003 11:02:13 -0700
| Lines: 27
| Message-ID: <[email protected]>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Thread-Index: AcN5V/5XIcokhX27R5ehiTD/j88/mQ==
| X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Newsgroups: microsoft.public.dotnet.framework.windowsforms
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl
microsoft.public.dotnet.framework.windowsforms:52257
| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
| X-Tomcat-NG: microsoft.public.dotnet.framework.windowsforms
|
| I have 2 forms, Form1 and Form2. Form1 contains a
| Windows.Forms.Timer component that triggers at 30 second
| intervals. At each 30 second interval, a synchronous
| WebService (WebService1), that returns an integer, is
| called. Form1 contains a button, that, when clicked,
| displays Form2 modelessly (i.e. Form2.Show()). Form2
| contains a button, and in it's click event a long (may
| take several minutes ) SQL query is run via an
| asynchronous WebService (WebService2) call. Everything
| works OK until the query starts running. Approximately, 1
| min and 30 seconds after the query starts running, the
| WebService call in Form1's timer tick eventhandler throws
| a "System.Net.WebException" w/ message "The operation has
| timed-out." About 1 min. 30 secs. after that, the Async
| WebMethod call in Form2 throws
| a "System.InvalidOperationException" w/ message "Client
| found response content type of 'text/html', but
| expected 'text/xml'. ...". To correct these errors
| I've: 1) tried changing the type of Timer used (b/c I
| thought it might be a threading issue) - but had the same
| errors, and 2) tried setting the Timeout property to
| Infinity for the synchronous WebMethod call in Form1 - but
| it still threw "InvalidOperationException" errors. Any
| other suggestions? It appears to me that the asynchronous
| WebService call is blocking the synchronous method call.
| Any ideas why?
|
|
 

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

Top