Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hello all, I know what I need to do, I just don't know how to code it in vb.net, please help.

 

 

I have a function that sends a message to another computer using a function in a dll file. I dont want to complete the function, untill the .dll returns a response. So i basically need to halt the program while I wait for a response. Not complete halt, just the flow of the application inside this function.

 

Please help!

-----------------------------------------------------

For example:

 

PUBLIC FUNCTION esStart

 

customDll.Start ("procedure start")

'

'this is where i need to wait for a response from an event

'

' WHEN MsgReceived - continue

 

END SUB

 

PUBLIC FUNCTION received (byval Test AS Object) handles customDll.MsgReceived

 

'this function is called when the program flow should continue

'

'MsgRecieved - CONTINUE!

 

END FUNCTION

 

 

------------------

www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
  • Leaders
Posted

something like this maybe ...


Private ReceivedResponse As Boolean = False

Public Sub esStart 

customDll.Start ("procedure start") 

While Not ReceivedResponse
   Application.DoEvents()
End While

'/// when ReceivedResponse becomes True , carry on.

End Sub

Public Function received (byval Test AS Object) handles customDll.MsgReceived 

ReceivedResponse = True

End Function

Posted
that looks like it may do the trick. I'll also need to probably do some type of timeout. Thanks.

 

How about trying this

 

Dim timeit As Integer = Environment.TickCount

 

While Not ReceivedResponse

if Environment.TickCount - timeit >= whateverMillisecondshere then

exit while

end if

Application.DoEvents()

End While

 

' and then to tell them there wasn't a response

 

if not recievedresponse then

messagebox.show("NO RESPONSE")

end if

Live as if you were to die tomorrow. Learn as if you were to live forever.
Gandhi
Posted

Upstairs's answer is very good

 

I have a try about his code,whith is very good one.

Thanks him for his super code and I hope he can help me in the future.

  • *Experts*
Posted
When creating a DLL project the Windows.Forms assembly is not imported by default, and that is where Application class is. You need to import the assembly.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...