D
Dan
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
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