473,414 Members | 1,750 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Pls help: a problem about IsHandleCreated property

AA
In my application, I create a form A and I pass the form A reference to another form B.
When I try to check the IsHandleCreated property of the form A, it always return false. So, I cannot call the begininvoke of the form A as the IsHandleCreated always return false.
Actually, the form A already show in the screen. WHy the IsHandleCreated is still false? When I call a function in formB, I want formA' s thread to call a function rather than using FormB's thread to call the function in form A.

Eg: It is some part of code in FormB.
if (frmA.IsHandleCreated)
{
frmA.BeginInvoke (new RefreshFunction (frmA.RefreshStrategy), new object[] {strategyid});
}

How to fix it this ptoblem?
Thanks

Anthony
Dec 5 '06 #1
5 6662
AA
When I ceate the formA, the code is below:
If there is any wrong for the creation of formA to trigger this problem, please let me know.

FormA a = new FormA();
a.Owner = this;

FormB b = new FormB();
b.Owner = this;
b.frmA = a;
Thanks
"AA" <aa@abc.com¼¶¼g©ó¶l¥ó·s»D:uO**************@TK2MSFT NGP05.phx.gbl....
In my application, I create a form A and I pass the form A reference to another form B.
When I try to check the IsHandleCreated property of the form A, it always return false. So, I cannot call the begininvoke of the form A as the IsHandleCreated always return false.
Actually, the form A already show in the screen. WHy the IsHandleCreated is still false? When I call a function in formB, I want formA' s thread to call a function rather than using FormB's thread to call the function in form A.

Eg: It is some part of code in FormB.
if (frmA.IsHandleCreated)
{
frmA.BeginInvoke (new RefreshFunction (frmA.RefreshStrategy), new object[] {strategyid});
}

How to fix it this ptoblem?
Thanks

Anthony
Dec 5 '06 #2
Why are you calling IsHandleCreated? A handle isn't necessarily created if it isn't needed. If you want to force a handle to be created simply access frmA.Handle. But again, what is the intent of your code by checking that before executing your delegate?
--
Tom Porterfield
"AA" <aa@abc.comwrote in message news:uO**************@TK2MSFTNGP05.phx.gbl...
In my application, I create a form A and I pass the form A reference to another form B.
When I try to check the IsHandleCreated property of the form A, it always return false. So, I cannot call the begininvoke of the form A as the IsHandleCreated always return false.
Actually, the form A already show in the screen. WHy the IsHandleCreated is still false? When I call a function in formB, I want formA' s thread to call a function rather than using FormB's thread to call the function in form A.

Eg: It is some part of code in FormB.
if (frmA.IsHandleCreated)
{
frmA.BeginInvoke (new RefreshFunction (frmA.RefreshStrategy), new object[] {strategyid});
}

How to fix it this ptoblem?
Thanks

Anthony
Dec 5 '06 #3
"AA" <aa@abc.comwrote in message news:OS**************@TK2MSFTNGP03.phx.gbl...
When I ceate the formA, the code is below:
If there is any wrong for the creation of formA to trigger this problem, please let me know.

FormA a = new FormA();
a.Owner = this;

FormB b = new FormB();
b.Owner = this;
b.frmA = a;
Thanks
"AA" <aa@abc.com¼¶¼g©ó¶l¥ó·s»D:uO**************@TK2MSFT NGP05.phx.gbl....
In my application, I create a form A and I pass the form A reference to another form B.
When I try to check the IsHandleCreated property of the form A, it always return false. So, I cannot call the begininvoke of the form A as the IsHandleCreated always return false.
Actually, the form A already show in the screen. WHy the IsHandleCreated is still false? When I call a function in formB, I want formA' s thread to call a function rather than using FormB's thread to call the function in form A.

Eg: It is some part of code in FormB.
if (frmA.IsHandleCreated)
{
frmA.BeginInvoke (new RefreshFunction (frmA.RefreshStrategy), new object[] {strategyid});
}

How to fix it this ptoblem?
Thanks

Anthony


Adding to what Tom said, you don't need to call BeginInvoke, both of your forms are created on the same thread, so there is no cross-thread marshaling needed.

Willy.
Dec 5 '06 #4
Actually,. the form B is create by another thread. Both FormA and FormB are not created by the same thread. But in my coding example, it may make you confuse.
When I call the frmA.BeginInvoke (new RefreshFunction (frmA.RefreshStrategy) , new object[] {strategyid}) in form B(create by another thread), it throw the exeption "Cannot call Invoke or InvokeAsync on a control until the window handle has been created."
So, when I check the IsHandleCreated od FOrmA, it shows false.

"Tom Porterfield" <tp******@mvps.orgwrote in message news:OC*************@TK2MSFTNGP04.phx.gbl...
Why are you calling IsHandleCreated? A handle isn't necessarily created if it isn't needed. If you want to force a handle to be created simply access frmA.Handle. But again, what is the intent of your code by checking that before executing your delegate?
--
Tom Porterfield
"AA" <aa@abc.comwrote in message news:uO**************@TK2MSFTNGP05.phx.gbl...
In my application, I create a form A and I pass the form A reference to another form B.
When I try to check the IsHandleCreated property of the form A, it always return false. So, I cannot call the begininvoke of the form A as the IsHandleCreated always return false.
Actually, the form A already show in the screen. WHy the IsHandleCreated is still false? When I call a function in formB, I want formA' s thread to call a function rather than using FormB's thread to call the function in form A.

Eg: It is some part of code in FormB.
if (frmA.IsHandleCreated)
{
frmA.BeginInvoke (new RefreshFunction (frmA.RefreshStrategy), new object[] {strategyid});
}

How to fix it this ptoblem?
Thanks

Anthony
Dec 6 '06 #5
<abc.comwrote in message news:eL**************@TK2MSFTNGP03.phx.gbl...
Actually,. the form B is create by another thread. Both FormA and FormB are not created by the same thread. But in my coding example, it may make you confuse.
When I call the frmA.BeginInvoke (new RefreshFunction (frmA.RefreshStrategy) , new object[] {strategyid}) in form B(create by another thread), it throw the exeption "Cannot call Invoke or InvokeAsync on a control until the window handle has been created."
So, when I check the IsHandleCreated od FOrmA, it shows false.
So as I said, if you ask for the handle (frmA.Handle) that will force it to be created if it isn't.
--
Tom Porterfield
Dec 6 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: MaxPenguin | last post by:
Hi All, I am banging my head against a brick wall over this problem, so any help in the correct direction would be muchly appreciated! I have 2 SQL (MS SQL) server tables, realated to -...
23
by: Jason | last post by:
Hi, I was wondering if any could point me to an example or give me ideas on how to dynamically create a form based on a database table? So, I would have a table designed to tell my application...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
5
by: ukjock | last post by:
Hi guys and Gals I need some serious help please. I can not get my head around this problem. At work we have a BBC Acorn computer (yep, I know what yer thinking), and for the past month I have...
16
by: Allen | last post by:
I have a class that returns an arraylist. How do I fill a list box from what is returned? It returns customers which is a arraylist but I cant seem to get the stuff to fill a list box. I just...
2
by: Carlo, MCP | last post by:
Hi, Sorry for posting twice, but I hope in your comprehension. Please help me! I'm troubling from months with a serious serialization problem that I'm not able to solve. I try to describe as...
13
by: sd00 | last post by:
Hi all, can someone give me some coding help with a problem that *should* be really simple, yet I'm struggling with. I need the difference between 2 times (Target / Actual) However, these times...
7
by: Donn Ingle | last post by:
Hi, I really hope someone can help me -- I'm stuck. I have written three versions of code over a week and still can't get past this problem, it's blocking my path to getting other code written. ...
1
by: =?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?= | last post by:
I get the above error in some of the ASP.NET web applications on a server, and I need some help figuring out how to deal with it. This is a rather long post, and I hope I have enough details that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.