473,394 Members | 1,642 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,394 software developers and data experts.

How to inform Parent thread from a Child Thread?

Hi all,
How to inform Parent thread from a Child Thread?
I mean want to notify something from Child thread to
Parent Thread.

Please help,
Thanks in advance,

-Regards,
Dinesh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #1
6 4132
Cor
Hi Dinish,

You can set a public event in a child thread that you can catch in a Parent
thread.

This is decribed in the walkthroughs for multithreading in/on MSDN

I hope this helps a little bit?

Cor
How to inform Parent thread from a Child Thread?
I mean want to notify something from Child thread to
Parent Thread.

Nov 20 '05 #2

Hi Cor,
Thanks for the reply.
Can you specify the link on where can I find the Walkthrough on MSDN
for threading?

Thanks in advance,

-Regards,
Dinesh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #3
Cor
Hi Dinesh,

This is one

http://msdn.microsoft.com/library/de...dComponent.asp

I hope this helps?

Cor
Nov 20 '05 #4

Hi Cor,
Thanks for the link. I have gone through some of the
subtopics.
Let me be specific about my problem-
I have a form which I am creating by calling "new"
from main thread. Then I am creating a subthread in which
I am accessing that form inside the subthread.
At some moment, I want to again call the "New" of that
form from the subthread. But I want that the New should be called by
Main thread.

How can I inform Main thread from my Sub thread about
to create new instance of that form?

Will Control.Invoke solve this problem?

Please help,
Thanks in advance,

-Regards,
Dinesh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 20 '05 #5
Cor
Hi Dinish,

You cannot reach a thread but from the thread you can reach a static
variable in your application.

I give you again a link, it is very few information, but I think with that
you have the solution.

http://msdn.microsoft.com/library/de...tmSyncLock.asp

Cor

Did you see this anouncement in this newsgroup.

I never know at what time it is, because they only give the times for
British and US people and a timetable accoording to GMT time but no GMT
time. Although I believe there is no BST time now also. It is almost
Christmass and that is not in summer in Britain.
----------------------------------------------------------------------------
-----------
Do you have questions about how to create multi-threaded applications? Or do
you wonder about what those threads are actually doing? Then join members of
the Visual Basic and .NET Framework teams as they answer your questions
about using threading with Visual Basic .NET.

Date:
November 25, 2003

Time:
1:00 - 2:00 P.M. Pacific time
4:00 - 5:00 P.M. Eastern time
21:00 - 22:00 BST/BST
(For a list of local time zones relative to GMT, please see
http://msdn.microsoft.com/chats/timezones.asp.)

Outlook Reminder:
http://msdn.microsoft.com/chats/outl...s/VB_Nov25.vcs

Location:
http://msdn.microsoft.com/chats (then click the name of the chat to enter
the chat room)

For more information about Visual Basic .NET, see
http://msdn.microsoft.com/vbasic/
To see a list of upcoming chats or set a reminder for this chat, see
http://msdn.microsoft.com/chats.
For archives of previous chats, see
http://msdn.microsoft.com/chats/recent.asp.

Thanks!
Jason Cooke
VB.NET Team
========
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use.
(c) 2003 Microsoft Corporation. All rights reserved.

Nov 20 '05 #6
Dinesh,
How can I inform Main thread from my Sub thread about
to create new instance of that form?

Will Control.Invoke solve this problem? Yes if you are attempting to notify a Form or other control, Control.Invoke
is the "best" way to go. You may need a separate hidden form, unless you
have a known main form, that your background thread can Control.Invoke on to
cause the new form to be created.

If you are attempting to notify a background thread from a Form. I normally
create a System.Collection.Queue object to hold the info I want to send, the
Form will enqueue requests onto the queue, the background will Dequeue
Requests from the queue. Of course you need to be certain to use Synclock to
ensure only one thread is modifying the queue at a time. Also I will use a
System.Threading.AutoResetEvent to notify the background thread that a new
item has appeared on the queue... Which means that when the background
thread is not processing a request it is waiting for an item on the queue,
the AutoResetEvent allows the background thread to go to sleep until an item
appears on the queue. This queue technique generally complicates your main
thread, hence its "better" to use a Form & Control.Invoke on your main
thread.

Hope this helps
Jay
"Dinesh Jain" <di*******@hotmail.com> wrote in message
news:eo**************@TK2MSFTNGP12.phx.gbl...
Hi Cor,
Thanks for the link. I have gone through some of the
subtopics.
Let me be specific about my problem-
I have a form which I am creating by calling "new"
from main thread. Then I am creating a subthread in which
I am accessing that form inside the subthread.
At some moment, I want to again call the "New" of that
form from the subthread. But I want that the New should be called by
Main thread.

How can I inform Main thread from my Sub thread about
to create new instance of that form?

Will Control.Invoke solve this problem?

Please help,
Thanks in advance,

-Regards,
Dinesh

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 20 '05 #7

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

Similar topics

8
by: Asad | last post by:
Hi, I am basically trying to accomplish drop down menus for navigation on a site. And I'm pretty much done except I am having one problem. The z-index is not working with relative positioning! ...
1
by: jinu | last post by:
Hello, My application loads with a form which is the mdi parent and a menu item click (main menu of the parent form) brings up a child form. I have to wait for a considerable amout of time to...
5
by: Dayne | last post by:
Can a Parent thread catch a event send by a child thread? Dayne
2
by: Manisha | last post by:
Hi, I am creating a C++ dll which is used to process data passed to it through one of its exported functions. It should be able to process 160 simultaneous requests. For this reason, I have...
25
by: Steve Jorgensen | last post by:
Yup, Steve's full of tips, but hey, it makes him feel important, right? Ok, here goes. I've been trying to improve encapsulation by putting code in the same object as the stuff it affects, so I...
10
by: Goran Djuranovic | last post by:
Hi all, Does anyone know how to declare a variable in a class to be accessible ONLY from a classes instantiated within that class? For example: ************* CODE ***************** Public...
3
by: joelq1981 | last post by:
Dear friends, I want to extend the interrupt handler of a program, my code is: ... if ($pid = fork) { local $SIG{INT} = sub { print "Please select:\n"; $choice =...
6
by: SQACSharp | last post by:
I'm using the EnumChildWindows API with an EnumChildWndProc callback to populate the treeview. The output will be something similar to spy+ + How can I specify the parent when adding a new node...
3
by: O.B. | last post by:
I have a form that shows another child form using the Show() operation. Since the child is modaless, I would like the option that when I click anywhere on the parent form that the parent form...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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...

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.