Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Finding the original thread in a Class Library

Posted on 2006-11-14
3
190 Views
Last Modified: 2010-04-16
I've created a class library which creates a seperate thread to do some of the work, how do i refer back to the original thread once its finished? In a winform i'd use invoke however it doesn't seem to exist in the class.
0
Comment
Question by:James_Wyatt
3 Comments
 
LVL 48

Expert Comment

by:AlexFM
ID: 17939094
You can raise event from this thread immediately before thread exits. In the caller class subscribe to this event. When event is raised, thread is "almost" finished. Notice that event handler is called in the context of worker thread.
0
 
LVL 12

Accepted Solution

by:
andrewjb earned 125 total points
ID: 17945681
....and thus doesn't solve the problem.


There's no 'built-in' way to cross thread boundaries, other than crossing into the GUI thread using Invoke(). You have to implement something yourself.

The simplest way would be something like a common variable that the worker thread sets and the original thread regularly polls to look for changes. (Don't forget a suitable lock() of course).

Alternatively you could use a mutex or semaphore or similar mechanism, or implement an equivalent to the Invoke() mechanism which would work on non-GUI threads.

I've ended up doing the latter since it's a complex multi-thread system, but hopefully a simpler option will do you..
0
 
LVL 1

Author Comment

by:James_Wyatt
ID: 17997100
Thanks for your help. In the end i used a passed a form to the dll so the it could use invoke().
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Sent email using Shared Mailbox from outlook in C# 5 50
Problem!!! 8 37
bound data table problem 2 33
jquery + C#.net radiobuttonlist 3 30
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project

860 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question