473,407 Members | 2,314 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,407 software developers and data experts.

Threading problem with MDI form

In an MDI app, from a child form I use BeginInvoke on a delegate to
start an async printing process. When it finishes, my callback
function (on the worker thread) calls me.BeginInvoke to get back to
the main thread where I update the status line on the MDI form
(Printing complete). This works fine, but the problem is that if the
user closes the child form before the printing is complete, the
callback executes but the main thread has now gone, so the MDI form
status bar doesn't get updated.

The worker thread at this point doesn't have an MdiParent. How can I
get back to the MDI form from the worker thread callback function to
update the status line?

Paul Shave
Jul 21 '05 #1
4 1444
Maybe you should pass reference of updated control to worker thread
callback? I would do that.

HTH
Alex

"Paul Shave" <ps******@yahoo.co.uk> wrote in message
news:8a**************************@posting.google.c om...
In an MDI app, from a child form I use BeginInvoke on a delegate to
start an async printing process. When it finishes, my callback
function (on the worker thread) calls me.BeginInvoke to get back to
the main thread where I update the status line on the MDI form
(Printing complete). This works fine, but the problem is that if the
user closes the child form before the printing is complete, the
callback executes but the main thread has now gone, so the MDI form
status bar doesn't get updated.

The worker thread at this point doesn't have an MdiParent. How can I
get back to the MDI form from the worker thread callback function to
update the status line?

Paul Shave

Jul 21 '05 #2
"AlexS" wrote ...
Maybe you should pass reference of updated control to worker thread
callback? I would do that.


The problem is that (because forms' controls are not thread-safe) you
are forbidden from updating a form's control from the worker thread -
you have to get back on to the main thread.

Paul
Jul 21 '05 #3
That's what for Invoke methods are.

HTH
Alex

"Paul Shave" <ps******@yahoo.co.uk> wrote in message
news:8a*************************@posting.google.co m...
"AlexS" wrote ...
Maybe you should pass reference of updated control to worker thread
callback? I would do that.


The problem is that (because forms' controls are not thread-safe) you
are forbidden from updating a form's control from the worker thread -
you have to get back on to the main thread.

Paul

Jul 21 '05 #4
"AlexS" wrote...
That's what for Invoke methods are.

But you can't do a Me.Invoke to get back to the main thread because
the child window's closed so there isn't one any more.

Paul
Jul 21 '05 #5

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

Similar topics

1
by: Andreas Neudecker | last post by:
Hi. I would like to learn how to do threading with Python. I have not done threading before can anyone suggest URLs where I could find understandable information on that? (I am using Python for...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
13
by: RCS | last post by:
I have a UI that needs a couple of threads to do some significant processing on a couple of different forms - and while it's at it, update the UI (set textboxes, fill in listviews). I created a...
1
by: Adam Honek | last post by:
In VB.Net we have nice simple threading as follows: Thread1 = New Threading.Thread(AddressOf DoSomething) The only problem so far I've come across is that the addressof must be a pointer to a...
0
by: blue_nirvana | last post by:
I have a program that automatically checks for an updated version on the network and if it finds it, it retrieves the new version and restarts. I have a splash screen that has an animated gif...
0
ammoos
by: ammoos | last post by:
hi friends pls help me.. i got an assignment which i feel very difficult to me.. i dont have more knowledge about multi-threading in .net... the assignment details is below.... pls help me... i...
0
by: SyGC | last post by:
Hi Guys, I have used Threading for Network.Ping to continuously ping an IP address if ping is successful Image A is displayed if not Image B. The code is as follows: Imports System Imports...
6
by: John | last post by:
Hi I am trying to create (not open) several forms in the background threads using the code given below at the end. 1. Am I doing it correctly? 2. How can I get handle sot these forms in the...
1
by: Girevik | last post by:
KeyPress doesn't work with Form at all... Why?
1
by: marciojersey | last post by:
Hi everyone. I'm having a problem with form opacity in my c# application. I have a window with a vrml viewer com control and whenever the window goes into layered mode, the vrml viewer is rendered...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.