Drstein99 Posted March 16, 2004 Posted March 16, 2004 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 ------------------ Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
Leaders dynamic_sysop Posted March 16, 2004 Leaders Posted March 16, 2004 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 Quote
Drstein99 Posted March 16, 2004 Author Posted March 16, 2004 that looks like it may do the trick. I'll also need to probably do some type of timeout. Thanks. Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
techmanbd Posted March 16, 2004 Posted March 16, 2004 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 Quote Live as if you were to die tomorrow. Learn as if you were to live forever. Gandhi
Horace Posted March 17, 2004 Posted March 17, 2004 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. Quote
Drstein99 Posted March 17, 2004 Author Posted March 17, 2004 not recognizing application.doevents in the form of my .dll Quote www.DRSTEIN99.com www.RAIDGEAR.net www.THERE.com -> Tell them DrStein99 sent ya!
*Experts* mutant Posted March 17, 2004 *Experts* Posted March 17, 2004 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.