<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff
size=2>Markus, </FONT></SPAN></DIV>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff size=2>I
believe you should see a single process with multiple threads. I usually
look at the CPU plots for each processor to determine whether all the threads
are computing.</FONT></SPAN></DIV>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff size=2>For
what you are trying to do, you probably want to use SpawnThread rather than
SingleMethodExecute. SingleMethodExecute is designed to execute the same
code over N threads. SingleMethodExecute actually only creates N-1
threads and uses the main thread as the Nth processing thread. So while
you can use SingleMethodExecute and set the number of threads to 1, you will not
actually spawn any additional threads. SpawnThread on the other hand will
always spawn a new thread. </FONT></SPAN></DIV>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff size=2>Note:
the Multithreader needs to be updated such that exceptions thrown in a spawned
thread are caught and propagated to the main thread. I have put this type
of code into the SingleMethodExecute but I still need to update
SpawnThread. If your spawned thread does not throw an exception, you
should be fine.</FONT></SPAN></DIV>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff
size=2>Depending on the optimizer used, you can actually do what you want
without threading. The registration framework should emit an iteration
event. You can attach an observer to the iteration event. Your
observer can peak at your event queue and process a few gui events. If the
user pressed the button to stop the registration, you can send set the Abort
flag on the registration. </FONT></SPAN></DIV>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff
size=2>Jim</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B> Markus Weigert
[mailto:m.weigert@fz-juelich.de]<BR><B>Sent:</B> Thursday, June 08, 2006 6:16
AM<BR><B>To:</B> Miller, James V (GE, Research);
insight-users@itk.org<BR><B>Subject:</B> Re: [Insight-users] ITK Threads with
memberfunctions<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Hi again,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I've done the threading now like it is done in
the ImageSource class.</FONT></DIV>
<DIV><FONT face=Arial size=2>But what I observe when I try to execute it, is
not what should happen.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I expected to see two different processes in the
Task Manager (Win XP),</FONT></DIV>
<DIV><FONT face=Arial size=2>when I
call SingleMethodExecute().</FONT></DIV>
<DIV><FONT face=Arial size=2>But this is not the case. </FONT><FONT face=Arial
size=2>I actually see two tasks of the programm, but only</FONT></DIV>
<DIV><FONT face=Arial size=2>a single process. I expected to have two
processes, which run in parallel,</FONT></DIV>
<DIV><FONT face=Arial size=2>one doing registration (the one which is newly
created) and the original one,</FONT></DIV>
<DIV><FONT face=Arial size=2>which is doing GUI staff
(FLTK).</FONT></DIV>
<DIV><FONT face=Arial size=2>I'm doing this to be able to stop the
registration process manually by observing the </FONT></DIV>
<DIV><FONT face=Arial size=2>optimizer.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV><FONT face=Arial size=2>Markus</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
<DIV style="FONT: 10pt arial">----- Original Message ----- </DIV>
<DIV
style="BACKGROUND: #e4e4e4; FONT: 10pt arial; font-color: black"><B>From:</B>
<A title=millerjv@crd.ge.com href="mailto:millerjv@crd.ge.com">Miller, James
V (GE, Research)</A> </DIV>
<DIV style="FONT: 10pt arial"><B>To:</B> <A title=m.weigert@fz-juelich.de
href="mailto:m.weigert@fz-juelich.de">Markus Weigert</A> ; <A
title=insight-users@itk.org
href="mailto:insight-users@itk.org">insight-users@itk.org</A> </DIV>
<DIV style="FONT: 10pt arial"><B>Sent:</B> Wednesday, June 07, 2006 10:41
PM</DIV>
<DIV style="FONT: 10pt arial"><B>Subject:</B> RE: [Insight-users] ITK
Threads with memberfunctions</DIV>
<DIV><BR></DIV>
<DIV><SPAN class=660033820-07062006><FONT face=Arial color=#0000ff
size=2>Marcus,</FONT></SPAN></DIV>
<DIV><SPAN class=660033820-07062006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=660033820-07062006><FONT face=Arial color=#0000ff
size=2>The pattern I use to have the multithreader call a static function
(or a standard C function) and pass the object as part of the
clientdata. The static method, then casts the clientdata back to the
object type and calls the member function that I wanted to
call.</FONT></SPAN></DIV>
<DIV><SPAN class=660033820-07062006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=660033820-07062006><FONT face=Arial color=#0000ff
size=2>This is how the multithreaded filters are implemented. Take a
look at ImageSource::GenerateData() and
ImageSource::ThreaderCallback().</FONT></SPAN></DIV>
<DIV><SPAN class=660033820-07062006><FONT face=Arial color=#0000ff
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=660033820-07062006><FONT face=Arial color=#0000ff
size=2>Jim</FONT></SPAN></DIV>
<BLOCKQUOTE dir=ltr style="MARGIN-RIGHT: 0px">
<DIV class=OutlookMessageHeader dir=ltr align=left><FONT face=Tahoma
size=2>-----Original Message-----<BR><B>From:</B>
insight-users-bounces+millerjv=crd.ge.com@itk.org
[mailto:insight-users-bounces+millerjv=crd.ge.com@itk.org]<B>On Behalf Of
</B>Markus Weigert<BR><B>Sent:</B> Wednesday, June 07, 2006 2:38
PM<BR><B>To:</B> insight-users@itk.org<BR><B>Subject:</B> [Insight-users]
ITK Threads with memberfunctions<BR><BR></FONT></DIV>
<DIV><FONT face=Arial size=2>Dear all,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I would like to make a programm, at which I'm
currenty </FONT></DIV>
<DIV><FONT face=Arial size=2>working, multithreaded.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>As far as I know, there is a class called
itkMultiThreader which</FONT></DIV>
<DIV><FONT face=Arial size=2>provides this functionality.</FONT></DIV>
<DIV><FONT face=Arial size=2>My question is, if this class can also be
used to create a thread</FONT></DIV>
<DIV><FONT face=Arial size=2>for a memberfunction of an object, because I
always receive compiler</FONT></DIV>
<DIV><FONT face=Arial size=2>complaints from VC6 on std_call problems
when I call SetSingleMethod().</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>As far as I know, </FONT><FONT face=Arial
size=2>for example posix threads only work with C-functions.</FONT></DIV>
<DIV><FONT face=Arial size=2>So, is this also true for the multithreader
or may the problem be different?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I think that for example, the threads from
Boost library can deal with member functions,</FONT></DIV>
<DIV><FONT face=Arial size=2>but I would not like to use a large library
only for one small feature.</FONT></DIV>
<DIV><FONT face=Arial size=2>Can you please give me a hint?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Regards,</FONT></DIV>
<DIV><FONT face=Arial size=2>Markus</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>PS: declaring the function as static is not
possible, </FONT></DIV>
<DIV><FONT face=Arial size=2>because it accesses non-static
members.</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>