.NETGURU
Delegates and Threads
Messages   Related Types
This message was discovered on microsoft.public.dotnet.languages.vc.

Post a new message to this list...

Howard Weiss
I am writing a Managed C++ image processing application which consists of a
main window and a number of image processing windows. The main window is a
Windows Forms and each image window is an instance of a different Windows
Form. The image windows are created by creating New instances of the image
form. The image forms become visible when I invoke show method.

Initially, I wrote my application as a single threaded application.
However, it takes considerable time to generate the images and I wish to
keep my UI interactive, so I am converting to a multi-threaded application.
At first, I created the image and invoked the show method for the images in
the worker thread. The images disappeared as soon as the worker thread
completes. I therefore created a delegate to invoke the show method from
within my UI thread.

Code in my main thread looks like

showImage(Image *Image)
{
Image->Show();
}

Code in my worker thread looks like

__delegate void delegateImageShow(Image *Image);

....
Image *pImageToDisplay;
delegateImageShow *pShow = new delegateImageShow(this, showImage);
pShow->Invoke(pImageToDisplay)
....

However, if I look at the HashCode of the thread which is running showImage,
it is the HashCode of the worker thread and not the HashCode of my UI
thread.

I am puzzled

Howard Weiss
__delegate void delegateImageActivated(int Index);

Reply to this message...
 
    
Howard Weiss
The solution was to use Invoke as follows

....
Object *pObject[] = {__box(pImage)};
Invoke(pShow, pObject);
.....

rather than

pShow_>Invoke()

Howard Weiss

"Howard Weiss" <Click here to reveal e-mail address> wrote in message
news:Click here to reveal e-mail address...
[Original message clipped]

Reply to this message...
 
 




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification