Re: Invoking a form that was created on a separate thread
- From: "Dannyboy" <daniel@xxxxxxxxxxxxxxxxxxxxxxx>
- Date: Fri, 15 Apr 2005 21:15:58 +0100
Hi Daniel thanks for that I shall go through your background worker code, I
do currently have a background process implemenation that is based on an
article written by Rocky Lhotka on msdn
http://msdn.microsoft.com/vbasic/using/columns/adventures/default.aspx?pull=/library/en-us/dnadvnet/html/vbnet09272002.asp
the trouble is the blasted form that is returned from that background
process throws an exception everytime I try and invoke its show method.
Should I be changing the implementation so that I don't do the parsing on
the background thread?
Dan
"Daniel Moth" <dmoth74@xxxxxxxxxxx> wrote in message
news:enGb7SfQFHA.508@xxxxxxxxxxxxxxxxxxxxxxx
> Check out the BackgroundWorker or do it yourself (parsing on thread and
> updating the form with control invoke)
>
> Cheers
> Daniel
> --
> http://www.danielmoth.com/Blog/
>
>
> "Dannyboy" <daniel@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
> news:%23bFkZNfQFHA.248@xxxxxxxxxxxxxxxxxxxxxxx
>> Hi Chris your right its not good all, the the thing is the xml files that
>> are being parsed are pretty big and they take quite a bit of time, so I
>> need to put a progress bar on, I did try creating that on the main the
>> and then updating that from a separate thread.
>>
>> If there is a better way to do this I'm open to all suggestions cos this
>> is p#@*ing me off
>>
>> Thanks
>> Dan
>> "Chris Tacke, eMVP" <ctacke@xxxxxxxxxxxxxxxxxxxxxx> wrote in message
>> news:u9%23zJ0dQFHA.1528@xxxxxxxxxxxxxxxxxxxxxxx
>>> The first question has to be why are you creating a Form on another
>>> thread? It's a very bad idea, a bad design, and bad practice.
>>>
>>>
>>> --
>>> Chris Tacke
>>> Co-founder
>>> OpenNETCF.org
>>> Has OpenNETCF helped you? Consider donating to support us!
>>> http://www.opennetcf.org/donate
>>>
>>>
>>> "Dan" <daniel@xxxxxxxxxxxxxxxxxxxxxxx> wrote in message
>>> news:e5x$vrdQFHA.3628@xxxxxxxxxxxxxxxxxxxxxxx
>>>> Hi everyone
>>>>
>>>> I have a class which parses an xml file and creates a form and its
>>>> controls from it, and I have recenlty moved this so that it happens on
>>>> its own thread, I know about controls that are created on a different
>>>> thread to the UI can not just have its methods called without using
>>>> invoke so with this I have tried several different ways to get the form
>>>> to show but I'm having problems.
>>>>
>>>> The ways I have have tried are:
>>>>
>>>> 1. With the form that is returned from the parsing class I have tried
>>>> me.invoke(new delegateSub(addressof newform.show))
>>>> This throws the error "Cannot call Invoke or InvokeAsync on a control
>>>> until the window handle has been created."
>>>>
>>>> 2. Add a controller class that is also created on the separate thread
>>>> which shows the form when the parsing is complete, this does show the
>>>> form briefly but it then disappears.
>>>>
>>>> 3. With the same controller class I use Application.Run(parsedform).
>>>> This works beautifully apart from one small snag, the class which
>>>> starts the parsing is passed a reference to the parser and acts as the
>>>> code behind for the the controls that are created in the parsed form
>>>> e.g. the click event of a button in the parsed form is handled by a
>>>> method in the class that is sent to the parser. This is where this
>>>> method seems to fall down because the reference no longer works.
>>>>
>>>> Am I fighting a loosing battle with this or can anyone offer some code
>>>> of wisdom.
>>>> Any help will be much appreciated.
>>>>
>>>> Many Thanks
>>>> Dan
>>>>
>>>>
>>>>
>>>>
>>>
>>>
>>
>>
>
.
- Follow-Ups:
- Re: Invoking a form that was created on a separate thread
- From: Daniel Moth
- Re: Invoking a form that was created on a separate thread
- References:
- Invoking a form that was created on a separate thread
- From: Dan
- Re: Invoking a form that was created on a separate thread
- From: Chris Tacke, eMVP
- Re: Invoking a form that was created on a separate thread
- From: Dannyboy
- Re: Invoking a form that was created on a separate thread
- From: Daniel Moth
- Invoking a form that was created on a separate thread
- Prev by Date: Re: CF 1.0 SP3 developer bits
- Next by Date: print programatically, and wireless printers
- Previous by thread: Re: Invoking a form that was created on a separate thread
- Next by thread: Re: Invoking a form that was created on a separate thread
- Index(es):
Loading