views:

143

answers:

1

Hello friends, I have a Web Service with Just one Web Method that returns a boolean value and a function

When a client application consumes this web Service, I first want to return a value true and then continue with the remaining process.

I was googling and didn't find anything that I can understand. Please help me out. In one of the message posts I saw threading as one option. I tried that too.

Below is the code for the same I commented the threading part please help

    <WebMethod()> _
    Public Function HelloWorld(ByVal str As String) As Boolean
        Dim status As Boolean = False
        If str <> "" Then
           'Dim t As New Thread(AddressOf ReturnWSStatus)
            't.Start()   
            Me.DoItNow()
        End If
        Return status
    End Function

  Public Shared Function ReturnWSStatus() As Boolean
        Return True
        'Thread.Sleep(0)
    End Function
A: 

You would need to do something like this:

<WebMethod()> Public Function HelloWorld(ByVal str As String) As Boolean
    Dim status As Boolean = False

    If str <> "" Then
        Dim t As New Thread(AddressOf DoItNow)
        t.Start()
        return true
    End If
End Function

Strictly speaking, the web method doesn't return before the additional processing starts, but it does return immediately after the new thread is launched, so the time difference is very small. Once you return from a method its execution is pretty much done, so whatever you want it to start needs to be started before the Return statement.

Chris Tybur