dart frog

dart frog

  • NA
  • 2
  • 2.6k

Threading Problem in Vb.net

Aug 26 2012 11:23 PM
Hi All,
 
I create vb.net application and i add one windows form,called frmScan.
i put two textboxes and two labels. Then i write the following
thread with delegate event.

Private Delegate Sub DoInitializedDelegate() 
 
Public motdet As New Thread(AddressOf MotionDetection)
 
Private Sub MotionDetection()
'Do motion detection Work
'It is never ending Loop until form unload.
End Sub

Then I start it in my form load event.

Private Sub frmScan_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load motdet.Start() End Sub

So my problem started when i load the form.
i can see the form but it is like loading something.
i thought my motion detecting thread is never ending loop until form unload.
i cannot type anything inside two text box i mentions in above.
how should i do ? pls help me.
thanks
best rgds,
df


Answers (1)

0
Vulpes

Vulpes

  • 0
  • 96k
  • 2.6m
Aug 28 2012 6:46 AM
I suspect the problem is that the form has not fully loaded when the other thread is started.

Rather than use the Load event, I'd try placing the code which starts the new thread in the Form's Shown event handler. This event won't be fired until the form has loaded and is displayed for the first time. It won't fire again after that.