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 5 6662
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
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
"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.
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
<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 This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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 -...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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.
...
|
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...
|
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
|
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...
|
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...
|
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,...
|
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...
|
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,...
|
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...
|
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...
|
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...
| |