|
-
July 19th, 2007, 06:51 AM
#1
Multithreaded consumer
Hi. I have a C# WebService with a WebMethod that returns an array of (WebService-defined) objects. If I create a consumer exe and call the method, everything is as expected.
If I then create a thread within my exe and call the WebMethod from there, my thread dies. No exception, it just dies. At one point I had a few unhandled socket exceptions mentioned in the Debug window, but something's changed and they're not appearing now.
Also, I can't step into the web service code from the new thread, but I can from the normal thread...
Here's the consumer code:
Code:
private void GetInfoButton_Click(object sender, EventArgs e)
{
if (CreateReference())
{
NetQCws.DynamicHostInfo[] infos = m_WS.GetDynamicHostInfo();
foreach (NetQCws.DynamicHostInfo inf in infos)
Debug.WriteLine(string.Format("ST: {0}@{1} last seen {2}", inf.Hostname, inf.IP_Address, inf.LastSeen.ToString("T")));
}
// and now threaded
System.Threading.Thread thr = new System.Threading.Thread(new System.Threading.ThreadStart(ThreadProc));
thr.Name = "info worker thread";
thr.Start();
}
private void ThreadProc()
{
NetQCws.Service svc = new NetQCClient.NetQCws.Service();
try
{
NetQCws.DynamicHostInfo[] infos = svc.GetDynamicHostInfo();
foreach (NetQCws.DynamicHostInfo inf in infos)
{
Debug.WriteLine("blah");
}
}
catch (Exception ex)
{
Debug.WriteLine(string.Format("ERROR: {0}", ex.Message));
}
}
Any clues?
Thanks for your time,
Toot
Some cause happiness wherever they go; others, whenever they go.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|