<!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.2873" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi Jim,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2>thanks for your reply.</FONT></DIV>
<DIV><FONT face=Arial size=2>I'm doing it now in the way, that I use a separate 
Thread</FONT></DIV>
<DIV><FONT face=Arial size=2>for the registration and one for observing the GUI 
with MultipleMethodExecute.</FONT></DIV>
<DIV><FONT face=Arial size=2>When the user clicks a cancel button, the observing 
thread</FONT></DIV>
<DIV><FONT face=Arial size=2>notices this and the IterationOberver of the 
optimizer will set the abort flag</FONT></DIV>
<DIV><FONT face=Arial size=2>on the registration.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
<DIV><FONT face=Arial size=2></FONT>&nbsp;</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> Thursday, June 08, 2006 4:46 
  PM</DIV>
  <DIV style="FONT: 10pt arial"><B>Subject:</B> RE: [Insight-users] ITK Threads 
  with memberfunctions</DIV>
  <DIV><FONT face=Arial size=2></FONT><FONT face=Arial size=2></FONT><FONT 
  face=Arial size=2></FONT><FONT face=Arial size=2></FONT><BR></DIV>
  <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>&nbsp;</DIV>
  <DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff size=2>I 
  believe you should see&nbsp; 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>&nbsp;</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.&nbsp; SingleMethodExecute is designed to execute the same 
  code over&nbsp;N threads.&nbsp; SingleMethodExecute actually only creates N-1 
  threads and uses the main thread as the Nth processing thread.&nbsp; So while 
  you can use SingleMethodExecute and set the number of threads to 1, you will 
  not actually spawn any additional threads.&nbsp; SpawnThread on the other hand 
  will always spawn a new thread.&nbsp; </FONT></SPAN></DIV>
  <DIV><SPAN class=987542614-08062006><FONT face=Arial color=#0000ff 
  size=2></FONT></SPAN>&nbsp;</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.&nbsp; I have 
  put this type of code into the SingleMethodExecute but I still need to update 
  SpawnThread.&nbsp; 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>&nbsp;</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.&nbsp; The registration framework should emit an iteration 
  event.&nbsp; You can attach an observer to the iteration event.&nbsp; Your 
  observer can peak at your event queue and process a few gui events.&nbsp; 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>&nbsp;</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>&nbsp;</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>&nbsp;</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&nbsp;I 
    call&nbsp;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&nbsp;doing GUI&nbsp;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>&nbsp;</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>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</DIV>
    <DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp;</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.&nbsp; 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>&nbsp;</DIV>
      <DIV><SPAN class=660033820-07062006><FONT face=Arial color=#0000ff 
      size=2>This is how the multithreaded filters are implemented.&nbsp; 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>&nbsp;</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>&nbsp;</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>&nbsp;</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&nbsp;create a thread</FONT></DIV>
        <DIV><FONT face=Arial size=2>for a memberfunction of an object, because 
        I always&nbsp;receive compiler</FONT></DIV>
        <DIV><FONT face=Arial size=2>complaints from VC6&nbsp;on std_call 
        problems when I call SetSingleMethod().</FONT></DIV>
        <DIV><FONT face=Arial size=2></FONT>&nbsp;</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>&nbsp;</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>&nbsp;</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>&nbsp;</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&nbsp;accesses non-static 
        members.</FONT></DIV></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BLOCKQUOTE></BODY></HTML>