Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Multithreading program!

Multithreading program!

Scheduled Pinned Locked Moved C#
helpquestion
7 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    TaiZhong
    wrote on last edited by
    #1

    I would like to create a method that within the method it will handle the mouse click event and after the user has input 2 points the method will return a value back to the caller. void Test(){ /* The Drawline method should allow user to click the left mouse button 2 times to accept 2 points,after that the DrawLine method will return a true value;*/ bool isDraw = DrawLine(); } Anyone know what should I do within the DrawLine() method? All help is appreciated. Thanks.

    A 1 Reply Last reply
    0
    • T TaiZhong

      I would like to create a method that within the method it will handle the mouse click event and after the user has input 2 points the method will return a value back to the caller. void Test(){ /* The Drawline method should allow user to click the left mouse button 2 times to accept 2 points,after that the DrawLine method will return a true value;*/ bool isDraw = DrawLine(); } Anyone know what should I do within the DrawLine() method? All help is appreciated. Thanks.

      A Offline
      A Offline
      Ashfield
      wrote on last edited by
      #2

      TaiZhong wrote:

      I would like to create a method that within the method it will handle the mouse click event and after the user has input 2 points the method will return a value back to the caller.

      What has this to do with multi-threading? Anyway, return what value back to the caller? What caller? You need to handle the mouse button down/up events I expect. Post your code for further assistance.

      Bob Ashfield Consultants Ltd

      T 1 Reply Last reply
      0
      • A Ashfield

        TaiZhong wrote:

        I would like to create a method that within the method it will handle the mouse click event and after the user has input 2 points the method will return a value back to the caller.

        What has this to do with multi-threading? Anyway, return what value back to the caller? What caller? You need to handle the mouse button down/up events I expect. Post your code for further assistance.

        Bob Ashfield Consultants Ltd

        T Offline
        T Offline
        TaiZhong
        wrote on last edited by
        #3

        I am sorry, I am not sure whether its something do to with multithreading or not. You can forget about the "caller" if this terms confuse you (Caller means those who call this DrawLine() method). I just want to know how to make the program to stop at the DrawLine() method and after I have accept 2 points from the mouse down button then will return a true value back from the DrawLine method and after that the program will proceed. void Test(){ /* The program should wait untill I accept 2 points from the mouse down event after that a true value will return by DrawLine() to "temp" variables */ bool temp= DrawLine(); } I don't know what should I handle within the DrawLine() method.

        L S 2 Replies Last reply
        0
        • T TaiZhong

          I am sorry, I am not sure whether its something do to with multithreading or not. You can forget about the "caller" if this terms confuse you (Caller means those who call this DrawLine() method). I just want to know how to make the program to stop at the DrawLine() method and after I have accept 2 points from the mouse down button then will return a true value back from the DrawLine method and after that the program will proceed. void Test(){ /* The program should wait untill I accept 2 points from the mouse down event after that a true value will return by DrawLine() to "temp" variables */ bool temp= DrawLine(); } I don't know what should I handle within the DrawLine() method.

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          The exact way describe is not possible in .NET or most languages for that matter. To do it (exactly) like you show, your language will need to support continuations (only Ruby and Scheme does that AFAIK). The solution to your problem is to rethink the problem, and design it so it can be handled by the platform/language.

          xacc.ide - now with TabsToSpaces support
          IronScheme - 1.0 alpha 4a out now (29 May 2008)

          T 1 Reply Last reply
          0
          • L leppie

            The exact way describe is not possible in .NET or most languages for that matter. To do it (exactly) like you show, your language will need to support continuations (only Ruby and Scheme does that AFAIK). The solution to your problem is to rethink the problem, and design it so it can be handled by the platform/language.

            xacc.ide - now with TabsToSpaces support
            IronScheme - 1.0 alpha 4a out now (29 May 2008)

            T Offline
            T Offline
            TaiZhong
            wrote on last edited by
            #5

            I am using a third party components and it is written by C# .NET and there is a method that works exactly like what I have described previously I wonder how they did it?

            1 Reply Last reply
            0
            • T TaiZhong

              I am sorry, I am not sure whether its something do to with multithreading or not. You can forget about the "caller" if this terms confuse you (Caller means those who call this DrawLine() method). I just want to know how to make the program to stop at the DrawLine() method and after I have accept 2 points from the mouse down button then will return a true value back from the DrawLine method and after that the program will proceed. void Test(){ /* The program should wait untill I accept 2 points from the mouse down event after that a true value will return by DrawLine() to "temp" variables */ bool temp= DrawLine(); } I don't know what should I handle within the DrawLine() method.

              S Offline
              S Offline
              SteveNY
              wrote on last edited by
              #6

              Just handle the mouse click event and have a counter var in your class, increment it each time the click event happens and call the drawline method, in the drawline method check the counter, if it's the amount you want (2 in your case) reset it back to 0 and return true.

              T 1 Reply Last reply
              0
              • S SteveNY

                Just handle the mouse click event and have a counter var in your class, increment it each time the click event happens and call the drawline method, in the drawline method check the counter, if it's the amount you want (2 in your case) reset it back to 0 and return true.

                T Offline
                T Offline
                TaiZhong
                wrote on last edited by
                #7

                I have a question, if you want the program to stop at a method (drawLine() in my case), isn't it there must be a loop inside that method and loop untill the user have click the mouse button 2 times and only stop the loop and return a value?

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups