Hello,

I am making a app that creates a thread to show a clipboard. If the
clipboard is double clicked, another window is displayed, the event is
handled inside the main app. What I would like to do is have the clipboard
use the main thread of the application that called it to handle the new
window. Is this possible and if so how would this be accomplished.


ie.

Form1 creates a thread and the thread displays Form2.

Form2 when double clicked raises an event that creates a new form (Form3).
The event is handled inside Form1.

How can I get Form3 to be managed by the main thread (Form1)?


Thanks,

Chuck

Re: Threading by Sijin

Sijin
Wed Dec 01 02:49:59 CST 2004

If Form3 is getting created from main thread as it seems to be, then
Form3 will be managed by the main thread only.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Charles A. Lackman wrote:
> Hello,
>
> I am making a app that creates a thread to show a clipboard. If the
> clipboard is double clicked, another window is displayed, the event is
> handled inside the main app. What I would like to do is have the clipboard
> use the main thread of the application that called it to handle the new
> window. Is this possible and if so how would this be accomplished.
>
>
> ie.
>
> Form1 creates a thread and the thread displays Form2.
>
> Form2 when double clicked raises an event that creates a new form (Form3).
> The event is handled inside Form1.
>
> How can I get Form3 to be managed by the main thread (Form1)?
>
>
> Thanks,
>
> Chuck
>
>

Re: Threading by Herfried

Herfried
Wed Dec 01 05:33:25 CST 2004

"Charles A. Lackman" <Charles@CreateItSoftware.net> schrieb:
> Form1 creates a thread and the thread displays Form2.
>
> Form2 when double clicked raises an event that creates a new form (Form3).
> The event is handled inside Form1.
>
> How can I get Form3 to be managed by the main thread (Form1)?

Create /all/ forms in the application's main (UI) thread. Only start
"operations" in a separate thread and use
'Control.Invoke'/'Control.BeginInvoke' to communicate in the thread -> UI
direction.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>


Re: Threading by Robby

Robby
Wed Dec 01 05:53:05 CST 2004


Let Form2 create Form3 by using a callback on Form1. This will create Form3
on the Form1 thread.

Robby


"Charles A. Lackman" <Charles@CreateItSoftware.net> wrote in message
news:ult$vl21EHA.3504@TK2MSFTNGP12.phx.gbl...
> Hello,
>
> I am making a app that creates a thread to show a clipboard. If the
> clipboard is double clicked, another window is displayed, the event is
> handled inside the main app. What I would like to do is have the
> clipboard use the main thread of the application that called it to handle
> the new window. Is this possible and if so how would this be
> accomplished.
>
>
> ie.
>
> Form1 creates a thread and the thread displays Form2.
>
> Form2 when double clicked raises an event that creates a new form (Form3).
> The event is handled inside Form1.
>
> How can I get Form3 to be managed by the main thread (Form1)?
>
>
> Thanks,
>
> Chuck
>



Re: Threading by Charles

Charles
Wed Dec 01 12:13:04 CST 2004

Hello and thank you for your assistance.

I have attempted to accomplish what I need using delegates with no success.
i.e.

//Button Click//
Dim PollThread As Threading.Thread
PollThread = New Threading.Thread(AddressOf PollThreadAddress)
PollThread.Start()
End Sub

Private Sub PollThreadAddress()
frm1PollDatabase.TopMost = True
frm1PollDatabase.ShowDialog()
End Sub

//Button Click inside frm1PollDatabase that raises an event inside the
Parent Form//
Delegate Sub FromMyPage()
Dim MyDeleg As FromMyPage

Private Sub ApplyMyPage
MyDeleg = New FromMyPage(AddressOf DelegateFromMyPage)
MyDeleg.Invoke()
End Sub

Private Sub DelegateFromMyPage()
frm1Modify.showdialog
End Sub

** frm1PollDatabase is created inside a new thread and must always be on
top, which works fine. But when the user wants to send that data from this
form to a new form (frm1Modify) the form is displayed but frm1PollDatabase
becomes disabled because of the Showdialog method. I cannot use show for
this form to be displayed. If the original thread (Main) displays this form
wont it prevent this problem? The above code did not keep frm1PollDatabase
from being disabled.

Thanks Again,
Chuck


"Charles A. Lackman" <Charles@CreateItSoftware.net> wrote in message
news:ult$vl21EHA.3504@TK2MSFTNGP12.phx.gbl...
> Hello,
>
> I am making a app that creates a thread to show a clipboard. If the
> clipboard is double clicked, another window is displayed, the event is
> handled inside the main app. What I would like to do is have the
> clipboard use the main thread of the application that called it to handle
> the new window. Is this possible and if so how would this be
> accomplished.
>
>
> ie.
>
> Form1 creates a thread and the thread displays Form2.
>
> Form2 when double clicked raises an event that creates a new form (Form3).
> The event is handled inside Form1.
>
> How can I get Form3 to be managed by the main thread (Form1)?
>
>
> Thanks,
>
> Chuck
>



Re: Threading by Robby

Robby
Wed Dec 01 16:53:23 CST 2004


Instead of threading could you just show as a normal top most form? When
the selection is made on frm1PollDatabase raise an event on the main form.
You could then create frm1Modify on the main form, fill it with the
properties needed from frm1PollDatabase, destroy frm1PollDatabase and then
show frm1Modify. Now the main form and frm1Modify are on the same thread
and can communicate easily while they do their own processes. This seems to
do the trick without all the unecessary threading.

Is there any reason why you have to thread?

Robby


"Charles A. Lackman" <Charles@CreateItSoftware.net> wrote in message
news:%238VnoF91EHA.1192@tk2msftngp13.phx.gbl...
> Hello and thank you for your assistance.
>
> I have attempted to accomplish what I need using delegates with no
> success. i.e.
>
> //Button Click//
> Dim PollThread As Threading.Thread
> PollThread = New Threading.Thread(AddressOf PollThreadAddress)
> PollThread.Start()
> End Sub
>
> Private Sub PollThreadAddress()
> frm1PollDatabase.TopMost = True
> frm1PollDatabase.ShowDialog()
> End Sub
>
> //Button Click inside frm1PollDatabase that raises an event inside the
> Parent Form//
> Delegate Sub FromMyPage()
> Dim MyDeleg As FromMyPage
>
> Private Sub ApplyMyPage
> MyDeleg = New FromMyPage(AddressOf DelegateFromMyPage)
> MyDeleg.Invoke()
> End Sub
>
> Private Sub DelegateFromMyPage()
> frm1Modify.showdialog
> End Sub
>
> ** frm1PollDatabase is created inside a new thread and must always be on
> top, which works fine. But when the user wants to send that data from
> this form to a new form (frm1Modify) the form is displayed but
> frm1PollDatabase becomes disabled because of the Showdialog method. I
> cannot use show for this form to be displayed. If the original thread
> (Main) displays this form wont it prevent this problem? The above code
> did not keep frm1PollDatabase from being disabled.
>
> Thanks Again,
> Chuck
>
>
> "Charles A. Lackman" <Charles@CreateItSoftware.net> wrote in message
> news:ult$vl21EHA.3504@TK2MSFTNGP12.phx.gbl...
>> Hello,
>>
>> I am making a app that creates a thread to show a clipboard. If the
>> clipboard is double clicked, another window is displayed, the event is
>> handled inside the main app. What I would like to do is have the
>> clipboard use the main thread of the application that called it to handle
>> the new window. Is this possible and if so how would this be
>> accomplished.
>>
>>
>> ie.
>>
>> Form1 creates a thread and the thread displays Form2.
>>
>> Form2 when double clicked raises an event that creates a new form
>> (Form3). The event is handled inside Form1.
>>
>> How can I get Form3 to be managed by the main thread (Form1)?
>>
>>
>> Thanks,
>>
>> Chuck
>>
>
>