tags:

views:

145

answers:

2

I have a Web Service with one WebMethod for which return value is boolean.

It accepts XML file as string and process data. How can I first return status as true and then call the ProcessData method.

As the processing data takes time I need to return true first and then process the data.

Please help.

[webmethod]
Public function receiveData(ByVal xmlstr as string) as boolean
dim status as boolean=false
try
  if xmlstr<>"" then
      ProcessData(xmlstr)
     status=true
  end if

catch

end try
return status
end function
A: 

The only way I can see around this is to call the ProcessData on another thread. Of course, multi-threading is easy to do wrong, and you'll need to understand it before using it, so I'm not going to post a code snippet, but point you to a few places to start:

http://msdn.microsoft.com/en-us/library/system.threading.thread.aspx

http://www.yoda.arachsys.com/csharp/threads/

David Stratton
+1  A: 

Hi,

If I understand you correctly, what your trying to achieve is a quick respond to the user while the ProcessData work at the back.

I was dealing with a similar situation. What I did was to create another webmethod (or another generic handler in my case) and called it using Async request

this way I made it separately work with no additional threading effort.

yn2
You are absolutely right. Thanks for the info.