How to make subroutine calls from one form to another non-blocking?

Not sure if this is possible, but I have 2 forms, F1, and F2. I would like F1 to make a subroutine call to F2 and while F2 subroutine is running, i would like F1 to continue to execute it's code. My understaning is that VB is single-threaded but i thought i had read somewhere that this is possible to do this.

Any help would be appreciated.

thanks bc

[357 byte] By [bcw] at [2007-12-16]
# 1

Imports System.Threading

Public Class Form1

Private Sub MainSub()

Dim NewThread As New Thread(AddressOf RunThreaded)

NewThread.Start()

End Sub

Private Sub RunThreaded()

'This is run once NewThread.Start() is called.

End Sub

End Class


Dustin_H at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 2
Hi Dustin,

Thanks for responding.

I am not using the VB .Net Framework, just plain old vanilla VB6. So in that case i don't think your code snippet will still work? I tried but get compile errors

bcw at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 3
Hi, Yes, VB6 is single threaded. There have been a few 'tweaks' possible to make it multithreaded, but they are generally very unstable.

You'd have to make a OCX control from the subroutine you want to call, and add it to your program as a reference.

if i remember correctly, vb6 will call code from a ocx and continue execution.

Dustin_H at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...
# 4

Even calls to a control will typically be single-threaded, i.e. the call will block. Threading in VB6 is mostly done with non-UI DLLs on the server side.

If you really want to do threading with a Windows Forms client app, you really should consider using VB.NET. Take a look at the VB Express beta 2 if you want to experiment with it: http://msdn.microsoft.com/VBasic/Express/.

Steven

StevenLees at 2007-9-9 > top of Msdn Tech,Visual Basic,Visual Basic General...