Threading

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Michael Culley

    Threading

    I have some code that returns an event on a different thread. This is
    causing all sorts of problems, so I would like to just call a method on the
    main thread of the app and eliminate the second thread. The very first thing
    I want to do anyway is show a modal window so I don't need a second thread.
    Being that I know very little about threads can anyone gimme a solutions.

    Thanks,
    Michael Culley


  • Jeffrey Tan[MSFT]

    #2
    RE: Threading


    Hi Michael,

    I think I do not quite understand your meanning.

    1.What does your "return an event" mean?
    Does it mean that your second thread fires this event or creates this event
    handler for the
    main thread?

    2.How did all your problem arise?
    Did they all cause by sychronization problem?
    I think you should show me where the problem is(such as sample code of
    reproducing these problem)

    3.Why you can eliminate the second thread by showing a modal window?

    Any details will help us have a clear understand of your problem.

    Thanks

    Best regards,
    Jeffrey Tan
    Microsoft Online Partner Support
    Get Secure! - www.microsoft.com/security
    This posting is provided "as is" with no warranties and confers no rights.

    --------------------
    | From: "Michael Culley" <mike@nospam.co m>
    | Subject: Threading
    | Date: Mon, 15 Sep 2003 17:40:04 +1000
    | Lines: 10
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
    | Message-ID: <us61Xy1eDHA.25 76@TK2MSFTNGP11 .phx.gbl>
    | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
    | NNTP-Posting-Host: cpe-144-137-26-13.vic.bigpond. net.au 144.137.26.13
    | Path:
    cpmsftngxa07.ph x.gbl!cpmsftngx a10.phx.gbl!TK2 MSFTNGXA05.phx. gbl!TK2MSFTNGP0 8
    .phx.gbl!TK2MSF TNGP11.phx.gbl
    | Xref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1841 09
    | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
    |
    | I have some code that returns an event on a different thread. This is
    | causing all sorts of problems, so I would like to just call a method on
    the
    | main thread of the app and eliminate the second thread. The very first
    thing
    | I want to do anyway is show a modal window so I don't need a second
    thread.
    | Being that I know very little about threads can anyone gimme a solutions.
    |
    | Thanks,
    | Michael Culley
    |
    |
    |

    Comment

    • Michael Culley

      #3
      Re: Threading

      Hi Jeffrey,

      Thanks for the reply. I am creating a process and responding to the
      Process_Exited event. This event appears to get called on a seperate thread.
      I would just like to eliminate this second thread and call a function as if
      it was called from the apps main thread. I've pasted in some sample code
      below.

      Thanks again,
      Michael Culley


      mProcess = new Process();
      mProcess.StartI nfo.FileName = "C:\\whatever\\ psp.exe";
      mProcess.Enable RaisingEvents = true;
      mProcess.Exited += new EventHandler(mP rocess_Exited);
      mProcess.Start( );

      .....

      private void mProcess_Exited (object sender, EventArgs e)
      {
      //Show modal form here
      //but want to do this from the apps main thread.
      }


      Comment

      • Jeffrey Tan[MSFT]

        #4
        Re: Threading


        Hi Michael,

        I think I understand your meanning.
        I debuged into the mProcess_Exited () method and found that this method ran
        in
        a seperate thread.

        I think this is by design. The .Net Framework uses this way to implement
        the Process object's
        Exited event.(Because this event related to 2 process, the event must
        invoke some inter-process
        communication, it can not be down through regular way).

        Can you show me what is the problem if you do not eliminate the second
        thread?
        May be I can provided you a workaround for this problem.

        Best regards,
        Jeffrey Tan
        Microsoft Online Partner Support
        Get Secure! - www.microsoft.com/security
        This posting is provided "as is" with no warranties and confers no rights.

        --------------------
        | From: "Michael Culley" <mike@nospam.co m>
        | References: <us61Xy1eDHA.25 76@TK2MSFTNGP11 .phx.gbl>
        <$6ch4Q$eDHA.33 20@cpmsftngxa07 .phx.gbl>
        | Subject: Re: Threading
        | Date: Tue, 16 Sep 2003 12:30:45 +1000
        | Lines: 27
        | X-Priority: 3
        | X-MSMail-Priority: Normal
        | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
        | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
        | Message-ID: <#p67Hq$eDHA.24 84@TK2MSFTNGP09 .phx.gbl>
        | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
        | NNTP-Posting-Host: cpe-144-137-26-13.vic.bigpond. net.au 144.137.26.13
        | Path:
        cpmsftngxa07.ph x.gbl!cpmsftngx a10.phx.gbl!TK2 MSFTNGXA05.phx. gbl!TK2MSFTNGP0 8
        ..phx.gbl!TK2MS FTNGP09.phx.gbl
        | Xref: cpmsftngxa07.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1843 81
        | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
        |
        | Hi Jeffrey,
        |
        | Thanks for the reply. I am creating a process and responding to the
        | Process_Exited event. This event appears to get called on a seperate
        thread.
        | I would just like to eliminate this second thread and call a function as
        if
        | it was called from the apps main thread. I've pasted in some sample code
        | below.
        |
        | Thanks again,
        | Michael Culley
        |
        |
        | mProcess = new Process();
        | mProcess.StartI nfo.FileName = "C:\\whatever\\ psp.exe";
        | mProcess.Enable RaisingEvents = true;
        | mProcess.Exited += new EventHandler(mP rocess_Exited);
        | mProcess.Start( );
        |
        | ....
        |
        | private void mProcess_Exited (object sender, EventArgs e)
        | {
        | //Show modal form here
        | //but want to do this from the apps main thread.
        | }
        |
        |
        |

        Comment

        • Michael Culley

          #5
          Re: Threading

          Hi Jeffrey,

          Thanks for taking the time to look at this. The main problem I have is that
          I show a modal form in the event but it is not really modal, it is possible
          for the user to still interact with other windows in the app. I also
          implement a copy-to-clipboard function on this modal form which throws an
          exception saying that ole operations cannot execute in this thread. I would
          just like to call another function as if the main thread is calling it.

          I am going to buy a book and learn about threads properly (it's about time I
          did), but if you have a quick solution in the mean time that would be great.

          Regards,
          Michael Culley


          "Jeffrey Tan[MSFT]" <v-jetan@online.mi crosoft.com> wrote in message
          news:s0pqe9BfDH A.3592@cpmsftng xa07.phx.gbl...[color=blue]
          >
          > Hi Michael,
          >
          > I think I understand your meanning.
          > I debuged into the mProcess_Exited () method and found that this method ran
          > in
          > a seperate thread.
          >
          > I think this is by design. The .Net Framework uses this way to implement
          > the Process object's
          > Exited event.(Because this event related to 2 process, the event must
          > invoke some inter-process
          > communication, it can not be down through regular way).
          >
          > Can you show me what is the problem if you do not eliminate the second
          > thread?
          > May be I can provided you a workaround for this problem.
          >
          > Best regards,
          > Jeffrey Tan
          > Microsoft Online Partner Support
          > Get Secure! - www.microsoft.com/security
          > This posting is provided "as is" with no warranties and confers no rights.
          >
          > --------------------
          > | From: "Michael Culley" <mike@nospam.co m>
          > | References: <us61Xy1eDHA.25 76@TK2MSFTNGP11 .phx.gbl>
          > <$6ch4Q$eDHA.33 20@cpmsftngxa07 .phx.gbl>
          > | Subject: Re: Threading
          > | Date: Tue, 16 Sep 2003 12:30:45 +1000
          > | Lines: 27
          > | X-Priority: 3
          > | X-MSMail-Priority: Normal
          > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
          > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
          > | Message-ID: <#p67Hq$eDHA.24 84@TK2MSFTNGP09 .phx.gbl>
          > | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
          > | NNTP-Posting-Host: cpe-144-137-26-13.vic.bigpond. net.au 144.137.26.13
          > | Path:
          >[/color]
          cpmsftngxa07.ph x.gbl!cpmsftngx a10.phx.gbl!TK2 MSFTNGXA05.phx. gbl!TK2MSFTNGP0 8[color=blue]
          > phx.gbl!TK2MSFT NGP09.phx.gbl
          > | Xref: cpmsftngxa07.ph x.gbl[/color]
          microsoft.publi c.dotnet.langua ges.csharp:1843 81[color=blue]
          > | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
          > |
          > | Hi Jeffrey,
          > |
          > | Thanks for the reply. I am creating a process and responding to the
          > | Process_Exited event. This event appears to get called on a seperate
          > thread.
          > | I would just like to eliminate this second thread and call a function as
          > if
          > | it was called from the apps main thread. I've pasted in some sample code
          > | below.
          > |
          > | Thanks again,
          > | Michael Culley
          > |
          > |
          > | mProcess = new Process();
          > | mProcess.StartI nfo.FileName = "C:\\whatever\\ psp.exe";
          > | mProcess.Enable RaisingEvents = true;
          > | mProcess.Exited += new EventHandler(mP rocess_Exited);
          > | mProcess.Start( );
          > |
          > | ....
          > |
          > | private void mProcess_Exited (object sender, EventArgs e)
          > | {
          > | //Show modal form here
          > | //but want to do this from the apps main thread.
          > | }
          > |
          > |
          > |
          >[/color]


          Comment

          • Jeffrey Tan[MSFT]

            #6
            Re: Threading


            Hi Michael,

            Yes, it seems of that when invoking clipboard method in a seperate
            thread, the exception will generate.
            Also, the Form.ShowDialog () method does not show modal dialog.

            I will do some research for you, I will rely to you after my research.

            Best regards,
            Jeffrey Tan
            Microsoft Online Partner Support
            Get Secure! - www.microsoft.com/security
            This posting is provided "as is" with no warranties and confers no rights.

            --------------------
            | From: "Michael Culley" <mike@nospam.co m>
            | References: <us61Xy1eDHA.25 76@TK2MSFTNGP11 .phx.gbl>
            <$6ch4Q$eDHA.33 20@cpmsftngxa07 .phx.gbl>
            <#p67Hq$eDHA.24 84@TK2MSFTNGP09 .phx.gbl>
            <s0pqe9BfDHA.35 92@cpmsftngxa07 .phx.gbl>
            | Subject: Re: Threading
            | Date: Wed, 17 Sep 2003 11:26:18 +1000
            | Lines: 97
            | X-Priority: 3
            | X-MSMail-Priority: Normal
            | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
            | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
            | Message-ID: <#rT5xqLfDHA.32 84@tk2msftngp13 .phx.gbl>
            | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
            | NNTP-Posting-Host: cpe-144-137-26-13.vic.bigpond. net.au 144.137.26.13
            | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl
            | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1853 02
            | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
            |
            | Hi Jeffrey,
            |
            | Thanks for taking the time to look at this. The main problem I have is
            that
            | I show a modal form in the event but it is not really modal, it is
            possible
            | for the user to still interact with other windows in the app. I also
            | implement a copy-to-clipboard function on this modal form which throws an
            | exception saying that ole operations cannot execute in this thread. I
            would
            | just like to call another function as if the main thread is calling it.
            |
            | I am going to buy a book and learn about threads properly (it's about
            time I
            | did), but if you have a quick solution in the mean time that would be
            great.
            |
            | Regards,
            | Michael Culley
            |
            |
            | "Jeffrey Tan[MSFT]" <v-jetan@online.mi crosoft.com> wrote in message
            | news:s0pqe9BfDH A.3592@cpmsftng xa07.phx.gbl...
            | >
            | > Hi Michael,
            | >
            | > I think I understand your meanning.
            | > I debuged into the mProcess_Exited () method and found that this method
            ran
            | > in
            | > a seperate thread.
            | >
            | > I think this is by design. The .Net Framework uses this way to implement
            | > the Process object's
            | > Exited event.(Because this event related to 2 process, the event must
            | > invoke some inter-process
            | > communication, it can not be down through regular way).
            | >
            | > Can you show me what is the problem if you do not eliminate the second
            | > thread?
            | > May be I can provided you a workaround for this problem.
            | >
            | > Best regards,
            | > Jeffrey Tan
            | > Microsoft Online Partner Support
            | > Get Secure! - www.microsoft.com/security
            | > This posting is provided "as is" with no warranties and confers no
            rights.
            | >
            | > --------------------
            | > | From: "Michael Culley" <mike@nospam.co m>
            | > | References: <us61Xy1eDHA.25 76@TK2MSFTNGP11 .phx.gbl>
            | > <$6ch4Q$eDHA.33 20@cpmsftngxa07 .phx.gbl>
            | > | Subject: Re: Threading
            | > | Date: Tue, 16 Sep 2003 12:30:45 +1000
            | > | Lines: 27
            | > | X-Priority: 3
            | > | X-MSMail-Priority: Normal
            | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
            | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
            | > | Message-ID: <#p67Hq$eDHA.24 84@TK2MSFTNGP09 .phx.gbl>
            | > | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
            | > | NNTP-Posting-Host: cpe-144-137-26-13.vic.bigpond. net.au 144.137.26.13
            | > | Path:
            | >
            |
            cpmsftngxa07.ph x.gbl!cpmsftngx a10.phx.gbl!TK2 MSFTNGXA05.phx. gbl!TK2MSFTNGP0 8
            | > phx.gbl!TK2MSFT NGP09.phx.gbl
            | > | Xref: cpmsftngxa07.ph x.gbl
            | microsoft.publi c.dotnet.langua ges.csharp:1843 81
            | > | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
            | > |
            | > | Hi Jeffrey,
            | > |
            | > | Thanks for the reply. I am creating a process and responding to the
            | > | Process_Exited event. This event appears to get called on a seperate
            | > thread.
            | > | I would just like to eliminate this second thread and call a function
            as
            | > if
            | > | it was called from the apps main thread. I've pasted in some sample
            code
            | > | below.
            | > |
            | > | Thanks again,
            | > | Michael Culley
            | > |
            | > |
            | > | mProcess = new Process();
            | > | mProcess.StartI nfo.FileName = "C:\\whatever\\ psp.exe";
            | > | mProcess.Enable RaisingEvents = true;
            | > | mProcess.Exited += new EventHandler(mP rocess_Exited);
            | > | mProcess.Start( );
            | > |
            | > | ....
            | > |
            | > | private void mProcess_Exited (object sender, EventArgs e)
            | > | {
            | > | //Show modal form here
            | > | //but want to do this from the apps main thread.
            | > | }
            | > |
            | > |
            | > |
            | >
            |
            |
            |

            Comment

            • Jeffrey Tan[MSFT]

              #7
              Re: Threading


              Hi Michael,

              Sorry for letting you waiting for so long time.

              I think you should use the messaging technology notifying the main thread to
              execute the related code.(Pinvoke the SendMessage API)

              Sample code listed below:

              public int msgid;
              [DllImport("user 32.dll")]
              public static extern bool PostMessage(Int Ptr hwnd,int wMsg,IntPtr
              wParam,IntPtr lParam);
              [DllImport("user 32.dll")]
              public static extern int RegisterWindowM essage(string lpstring );

              private void mProcess_Exited (object sender, EventArgs e)
              {
              int msg=RegisterWin dowMessage("Not ify");
              this.msgid=msg;
              bool rel=PostMessage (this.Handle ,msg,IntPtr.Zer o,IntPtr.Zero );
              }

              protected override void WndProc(ref Message m)
              {
              // Listen for operating system messages.
              if(m.Msg ==this.msgid)
              {
              Form2 f2=new Form2();
              f2.ShowDialog(t his);
              }
              base.WndProc(re f m);
              }

              It works well on my machine, if you still have any question, please feel
              free
              to let me know , I am glad to work with you.

              Best regards,
              Jeffrey Tan
              Microsoft Online Partner Support
              Get Secure! - www.microsoft.com/security
              This posting is provided "as is" with no warranties and confers no rights.

              --------------------
              | From: "Michael Culley" <mike@nospam.co m>
              | References: <us61Xy1eDHA.25 76@TK2MSFTNGP11 .phx.gbl>
              <$6ch4Q$eDHA.33 20@cpmsftngxa07 .phx.gbl>
              <#p67Hq$eDHA.24 84@TK2MSFTNGP09 .phx.gbl>
              <s0pqe9BfDHA.35 92@cpmsftngxa07 .phx.gbl>
              | Subject: Re: Threading
              | Date: Wed, 17 Sep 2003 11:26:18 +1000
              | Lines: 97
              | X-Priority: 3
              | X-MSMail-Priority: Normal
              | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
              | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
              | Message-ID: <#rT5xqLfDHA.32 84@tk2msftngp13 .phx.gbl>
              | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
              | NNTP-Posting-Host: cpe-144-137-26-13.vic.bigpond. net.au 144.137.26.13
              | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!tk2 msftngp13.phx.g bl
              | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1853 02
              | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
              |
              | Hi Jeffrey,
              |
              | Thanks for taking the time to look at this. The main problem I have is
              that
              | I show a modal form in the event but it is not really modal, it is
              possible
              | for the user to still interact with other windows in the app. I also
              | implement a copy-to-clipboard function on this modal form which throws an
              | exception saying that ole operations cannot execute in this thread. I
              would
              | just like to call another function as if the main thread is calling it.
              |
              | I am going to buy a book and learn about threads properly (it's about
              time I
              | did), but if you have a quick solution in the mean time that would be
              great.
              |
              | Regards,
              | Michael Culley
              |
              |
              | "Jeffrey Tan[MSFT]" <v-jetan@online.mi crosoft.com> wrote in message
              | news:s0pqe9BfDH A.3592@cpmsftng xa07.phx.gbl...
              | >
              | > Hi Michael,
              | >
              | > I think I understand your meanning.
              | > I debuged into the mProcess_Exited () method and found that this method
              ran
              | > in
              | > a seperate thread.
              | >
              | > I think this is by design. The .Net Framework uses this way to implement
              | > the Process object's
              | > Exited event.(Because this event related to 2 process, the event must
              | > invoke some inter-process
              | > communication, it can not be down through regular way).
              | >
              | > Can you show me what is the problem if you do not eliminate the second
              | > thread?
              | > May be I can provided you a workaround for this problem.
              | >
              | > Best regards,
              | > Jeffrey Tan
              | > Microsoft Online Partner Support
              | > Get Secure! - www.microsoft.com/security
              | > This posting is provided "as is" with no warranties and confers no
              rights.
              | >
              | > --------------------
              | > | From: "Michael Culley" <mike@nospam.co m>
              | > | References: <us61Xy1eDHA.25 76@TK2MSFTNGP11 .phx.gbl>
              | > <$6ch4Q$eDHA.33 20@cpmsftngxa07 .phx.gbl>
              | > | Subject: Re: Threading
              | > | Date: Tue, 16 Sep 2003 12:30:45 +1000
              | > | Lines: 27
              | > | X-Priority: 3
              | > | X-MSMail-Priority: Normal
              | > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
              | > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
              | > | Message-ID: <#p67Hq$eDHA.24 84@TK2MSFTNGP09 .phx.gbl>
              | > | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
              | > | NNTP-Posting-Host: cpe-144-137-26-13.vic.bigpond. net.au 144.137.26.13
              | > | Path:
              | >
              |
              cpmsftngxa07.ph x.gbl!cpmsftngx a10.phx.gbl!TK2 MSFTNGXA05.phx. gbl!TK2MSFTNGP0 8
              | > phx.gbl!TK2MSFT NGP09.phx.gbl
              | > | Xref: cpmsftngxa07.ph x.gbl
              | microsoft.publi c.dotnet.langua ges.csharp:1843 81
              | > | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
              | > |
              | > | Hi Jeffrey,
              | > |
              | > | Thanks for the reply. I am creating a process and responding to the
              | > | Process_Exited event. This event appears to get called on a seperate
              | > thread.
              | > | I would just like to eliminate this second thread and call a function
              as
              | > if
              | > | it was called from the apps main thread. I've pasted in some sample
              code
              | > | below.
              | > |
              | > | Thanks again,
              | > | Michael Culley
              | > |
              | > |
              | > | mProcess = new Process();
              | > | mProcess.StartI nfo.FileName = "C:\\whatever\\ psp.exe";
              | > | mProcess.Enable RaisingEvents = true;
              | > | mProcess.Exited += new EventHandler(mP rocess_Exited);
              | > | mProcess.Start( );
              | > |
              | > | ....
              | > |
              | > | private void mProcess_Exited (object sender, EventArgs e)
              | > | {
              | > | //Show modal form here
              | > | //but want to do this from the apps main thread.
              | > | }
              | > |
              | > |
              | > |
              | >
              |
              |
              |

              Comment

              • Michael Culley

                #8
                Re: Threading

                "Jeffrey Tan[MSFT]" <v-jetan@online.mi crosoft.com> wrote in message
                news:ysjrAWcfDH A.2596@cpmsftng xa06.phx.gbl...[color=blue]
                > I think you should use the messaging technology notifying the main thread[/color]
                to[color=blue]
                > execute the related code.(Pinvoke the SendMessage API)[/color]

                Hi Jeff,

                Thanks for the reply. I was considering something like this but found a
                built in solution that does the same thing. The solution was to use
                this.Invoke(Del egate), this is a form or control. From what I can tell this
                sends a message to the window. This means that the window doesn't process
                the message until it is idle. This is perfect because it doesn't interupt
                running code until it is completed.

                Thanks for your help.

                Cheers,
                Michael Culley


                Comment

                • Jeffrey Tan[MSFT]

                  #9
                  Re: Threading


                  Hi Michael,

                  Yes, it seems that it really works well using invoke method.
                  I am glad that it works finally.

                  Best regards,
                  Jeffrey Tan
                  Microsoft Online Partner Support
                  Get Secure! - www.microsoft.com/security
                  This posting is provided "as is" with no warranties and confers no rights.

                  --------------------
                  | From: "Michael Culley" <mculley@optush ome.com.au>
                  | References: <us61Xy1eDHA.25 76@TK2MSFTNGP11 .phx.gbl>
                  <$6ch4Q$eDHA.33 20@cpmsftngxa07 .phx.gbl>
                  <#p67Hq$eDHA.24 84@TK2MSFTNGP09 .phx.gbl>
                  <s0pqe9BfDHA.35 92@cpmsftngxa07 .phx.gbl>
                  <#rT5xqLfDHA.32 84@tk2msftngp13 .phx.gbl>
                  <ysjrAWcfDHA.25 96@cpmsftngxa06 .phx.gbl>
                  | Subject: Re: Threading
                  | Date: Sun, 28 Sep 2003 10:46:02 +1000
                  | Lines: 21
                  | X-Priority: 3
                  | X-MSMail-Priority: Normal
                  | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
                  | X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
                  | Message-ID: <euZNgmVhDHA.16 72@TK2MSFTNGP12 .phx.gbl>
                  | Newsgroups: microsoft.publi c.dotnet.langua ges.csharp
                  | NNTP-Posting-Host: c210-49-163-120.chirn1.vic. optusnet.com.au
                  210.49.163.120
                  | Path: cpmsftngxa06.ph x.gbl!TK2MSFTNG P08.phx.gbl!TK2 MSFTNGP12.phx.g bl
                  | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.langua ges.csharp:1877 38
                  | X-Tomcat-NG: microsoft.publi c.dotnet.langua ges.csharp
                  |
                  | "Jeffrey Tan[MSFT]" <v-jetan@online.mi crosoft.com> wrote in message
                  | news:ysjrAWcfDH A.2596@cpmsftng xa06.phx.gbl...
                  | > I think you should use the messaging technology notifying the main
                  thread
                  | to
                  | > execute the related code.(Pinvoke the SendMessage API)
                  |
                  | Hi Jeff,
                  |
                  | Thanks for the reply. I was considering something like this but found a
                  | built in solution that does the same thing. The solution was to use
                  | this.Invoke(Del egate), this is a form or control. From what I can tell
                  this
                  | sends a message to the window. This means that the window doesn't process
                  | the message until it is idle. This is perfect because it doesn't interupt
                  | running code until it is completed.
                  |
                  | Thanks for your help.
                  |
                  | Cheers,
                  | Michael Culley
                  |
                  |
                  |

                  Comment

                  Working...