Home All Groups Group Topic Archive Search About

Thread terminating instantly

Author
6 May 2006 1:43 AM
Adam Honek
Hi all,

I'm launching a form in a new thread as follows below. The problem is the
form exits straight away.

How do I cause it to stay open until the form is closed?

The suspend won't work since I need to get UI events from the form controls.

Dim MyThread As System.Threading.Thread

MyThread = New System.Threading.Thread(AddressOf LaunchAccountsForm)

Call MyThread.Start()

Thanks,
Adam

Author
6 May 2006 2:03 AM
Chris
Adam Honek wrote:
Show quoteHide quote
> Hi all,
>
> I'm launching a form in a new thread as follows below. The problem is the
> form exits straight away.
>
> How do I cause it to stay open until the form is closed?
>
> The suspend won't work since I need to get UI events from the form controls.
>
> Dim MyThread As System.Threading.Thread
>
> MyThread = New System.Threading.Thread(AddressOf LaunchAccountsForm)
>
> Call MyThread.Start()
>
> Thanks,
> Adam
>
>

You should launch a UI element in a new thread.

But since you didn't show the code that you used to open the form we can
only guess.  I'd guess you are using .Show instead of .Showdialog.  But
like I said, you should look at how you are doing this because all your
UI elements should stay in the same thread.

Chris
Author
6 May 2006 2:31 AM
Adam Honek
Thanks a lot, yes showdialog did it.

It's just a config form that doesn't need to interact with the main form
hence
I'm not worried about joining the threads together.

Adam

Show quoteHide quote
"Chris" <no@spam.com> wrote in message
news:OU6n$ELcGHA.3352@TK2MSFTNGP03.phx.gbl...
> Adam Honek wrote:
>> Hi all,
>>
>> I'm launching a form in a new thread as follows below. The problem is the
>> form exits straight away.
>>
>> How do I cause it to stay open until the form is closed?
>>
>> The suspend won't work since I need to get UI events from the form
>> controls.
>>
>> Dim MyThread As System.Threading.Thread
>>
>> MyThread = New System.Threading.Thread(AddressOf LaunchAccountsForm)
>>
>> Call MyThread.Start()
>>
>> Thanks,
>> Adam
>
> You should launch a UI element in a new thread.
>
> But since you didn't show the code that you used to open the form we can
> only guess.  I'd guess you are using .Show instead of .Showdialog.  But
> like I said, you should look at how you are doing this because all your UI
> elements should stay in the same thread.
>
> Chris