(Alex Brown)
12/26/2002 3:30:00 AM
I am trying to spawn a thread inside of a web service method. It
compiles just fine, but when I try to test the service I get the
following exception:
"System.Threading.Thread cannot be serialized because it does not have
a default public constructor"
Obviously a thread is not serializable, but I'm not returning a
thread! Does every object used inside this function have to be
serializable? Is it possible that you just can't spawn a thread inside
a web service method? If anyone has tried this, I could use your help.
Thanks!
Alex Brown
Here is my function:
<WebMethod()> Public Function BeginOptimizing() As Boolean
Dim Solver As New SolverForm.Optimizer( _
LogPath, _
ConnectionStr, _
ScenarioID, _
AccountID, _
Guid _
)
Dim SolverThread As Thread
SolverThread = New Thread(AddressOf Solver.BeginOptimizing)
SolverThread.Name = "foo"
SolverThread.Start()
Application(SolverThread.Name) = SolverThread
Return True
End Function