Problem Passing DataSet through Async Proxy

D

Dustin

All,

I have a windows service that passes a dataset to a webmethod. The
webmethod then puts the dataset into a private message queue. I
created the proxy for the webmethod in visual studio, by adding a
reference to the webmethod, not using wsdl.exe manually.

Initially I flushed out the code calling the synchronous version of the
generated proxy for the webmethod. This worked fine and I was able to
see the datasets transferred properly to the private queue via the
webmethod.

Subsequently I changed the implementation to use the asynchronous
version of the webmethod's proxy. Everything seemed to be working
fine, datasets were arriving in the private queue and callbacks firing
fine.

Today I implemented the queue drainer and found that there were no rows
in the datasets that I was pulling out of the private queue. After
awhile I traced it back to the fact that there were no rows in the
dataset received by the webmethod. It turns out that if I revert to
calling the synchronous version of the proxy, the dataset is properly
transferred (with rows) to the webmethod and subsequently to the
private queue.

I have attempted to regenerate the proxy and there is no change in
behavior.

This seems quite odd. Does anyone have reference indicating that a
difference exists between the serialization performed on datasets in
synchronous calls vs. asynchronous calls?

Thanks in advance,

Dustin
Newbrook Solutions
www.newbrooksolutions.com
 
D

Dan Rogers

Hi Dustin,

I think I saw ar related thread a while back. There are apparently
threading access issues that are intrinsic to data sets - but this is just
anecdotal based on threads I saw discussing this at an earlier time. I
would suspect that the second thread that is servicing the background call
is unable to read the data from the dataset that was created by the
foreground thread.

As a remedy, try serializing the dataset to XML, and then passing the
XMLDocument to the web method in your proxy.

I hope this helps

Dan Rogers
Microsoft Corporation
--------------------
 
D

Dustin

Dan said:
Hi Dustin,

I think I saw ar related thread a while back. There are apparently
threading access issues that are intrinsic to data sets - but this is just
anecdotal based on threads I saw discussing this at an earlier time. I
would suspect that the second thread that is servicing the background call
is unable to read the data from the dataset that was created by the
foreground thread.

As a remedy, try serializing the dataset to XML, and then passing the
XMLDocument to the web method in your proxy.

I hope this helps

Dan Rogers
Microsoft Corporation

I found that the error was occuring due to a race condition. The
BeginInvoke() method of the proxy does not generate a deep copy of the
DataSet. I was making a call to the DataSet.Clear() method after
calling my web proxy. In the synchronous call this works fine as the
dataset has already been serialized and sent. In the asynchronous call
it causes the DataSet to be cleared before the DataSet is actually
serialized down (at least this is my best guess). I removed the call to
DataSet.Clear() and it is working fine.

Dustin
 

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,755
Messages
2,569,536
Members
45,011
Latest member
AjaUqq1950

Latest Threads

Top