API to wait until an object is created properly??

R

raghudr

Hi all,

I have created lot of controls on a form

what i want to do is for wait until handles are created.

how can we do this??

say rag=new label();

i want to wait until the rag handle has been created.This is necessary
when i restart my system since all my app will be launched as a
windows service and i am getting expections like

"Invoke or begininvoke cannot be called on a control until the window
handle has been created".

Please help me in this i want to know which are the API's used for
this and how to do it??

I want to avoid sleep

thanks in advance,
RAGHU
 
K

Kerem Gümrükcü

Hi Raghu,

have a look at these:

Control..::.HandleCreated Event
Control..::.HandleDestroyed Event
Control..::.IsHandleCreated Property
Control..::.OnHandleCreated Method


Regards

Kerem

--
 
R

raghudr

[...]
i want to wait until the rag handle has been created.This is necessary
when i restart my system since all my app will be launched as  a
windows service and i am getting expections like
"Invoke or begininvoke cannot be called on a control until the window
handle has been created".
Please help me in this i want to know which are the API's used for
this and how to do it??

There is probably some reasonable, high-level way to structure your  
program so that it doesn't try to access Control instances until after  
their window handle is created, even notwithstanding the events Kerem  
mentions.

But, an actual service shouldn't be doing GUI stuff anyway.  Either you're  
misusing the term service, or there's a broader design problem going on  
here.

A concise-but-complete code sample would probably clear things up a lot  
better than a general description.

Pete

Hi pete,

Main problem is:


1)I have created a thread.which shows a splash screen(which is nothing
but a form with borders taken out).

2)now i do rag=new form();
then rag.showdialog();

3)And my application is very big.
all my application will be launched as a windows service

4)By the time my thread initilizes and rag has a valid value.A call
will be made from other application to end the splash

so i will be call invoke method to end the splash screen and then end
the thread.

but since the handle is not having proper value i get an exception.

this problem happens only during the restart of a system rest all
times it is working fine

please reply on this

thanks,
RAGHU
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top