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. Odd threads

Odd threads

Scheduled Pinned Locked Moved C#
helpdebuggingquestion
9 Posts 2 Posters 1 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.
  • C Offline
    C Offline
    Christer Claesson
    wrote on last edited by
    #1

    I have a very odd problem with J# and threads. I have a client with a gui and a connection class that is in another thread. At first only parts of the GUI loads, most tabs are not added at this point. Then I connect and check for password, if that is correct I want to load the other tabs. Oddly it loads the first one and that one is empty. The connection class in an observer that the GUI is listening at. And when I debug I get this error message: "An unhandlet exception of type 'System.ArgumentException' occured in system.windows.forms.dll Additional information: Controls created on one thread cannot be parented to a control on a different thread" Any idea what might be wrong?

    D C 2 Replies Last reply
    0
    • C Christer Claesson

      I have a very odd problem with J# and threads. I have a client with a gui and a connection class that is in another thread. At first only parts of the GUI loads, most tabs are not added at this point. Then I connect and check for password, if that is correct I want to load the other tabs. Oddly it loads the first one and that one is empty. The connection class in an observer that the GUI is listening at. And when I debug I get this error message: "An unhandlet exception of type 'System.ArgumentException' occured in system.windows.forms.dll Additional information: Controls created on one thread cannot be parented to a control on a different thread" Any idea what might be wrong?

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      First, this forum is for C#, not J#. *** Note to Admins: We need to create a J# Forum! *** :-D Is your connection class creating the controls? From a design standpoint, it really shouldn't be doing this. It's a connection class, not a GUI class... But if you must, you would have to supply a delegate function on your form for the connection class to call using wheteverFormName.Invoke(). This function would then have to create the new controls. The controls absolutely cannot be created directly by the connection class. RageInTheMachine9532 "...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome

      C 1 Reply Last reply
      0
      • C Christer Claesson

        I have a very odd problem with J# and threads. I have a client with a gui and a connection class that is in another thread. At first only parts of the GUI loads, most tabs are not added at this point. Then I connect and check for password, if that is correct I want to load the other tabs. Oddly it loads the first one and that one is empty. The connection class in an observer that the GUI is listening at. And when I debug I get this error message: "An unhandlet exception of type 'System.ArgumentException' occured in system.windows.forms.dll Additional information: Controls created on one thread cannot be parented to a control on a different thread" Any idea what might be wrong?

        C Offline
        C Offline
        Christer Claesson
        wrote on last edited by
        #3

        Ok, walking away from java threads and into delegates and threads. Anyhow would work better in theory I guess. But even though I follow this: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv\_vjsharp/html/vjwlkwalkthroughauthoringsimplemultithreadedcomponentwithvisualj.asp guide more or less exact, I get errors. VS.NET refuses to use System.Delegate.Combine(eventHandler, eventHandler): public delegate void FactorialCompleteHandler(double Factorial, double TotalCalculations); public FactorialCompleteHandler FactorialComplete; public void add_FactorialComplete(FactorialCompleteHandler e) { FactorialComplete = (FactorialCompleteHandler) System.Delegate.Combine(this.FactorialComplete, e); } That is all of the relevant code from the walkthrough but for some reason it wont work. Gets a: Cannot find method 'Combine(objectHandler, objectHandler)' in 'System.Delegate'

        D 1 Reply Last reply
        0
        • C Christer Claesson

          Ok, walking away from java threads and into delegates and threads. Anyhow would work better in theory I guess. But even though I follow this: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dv\_vjsharp/html/vjwlkwalkthroughauthoringsimplemultithreadedcomponentwithvisualj.asp guide more or less exact, I get errors. VS.NET refuses to use System.Delegate.Combine(eventHandler, eventHandler): public delegate void FactorialCompleteHandler(double Factorial, double TotalCalculations); public FactorialCompleteHandler FactorialComplete; public void add_FactorialComplete(FactorialCompleteHandler e) { FactorialComplete = (FactorialCompleteHandler) System.Delegate.Combine(this.FactorialComplete, e); } That is all of the relevant code from the walkthrough but for some reason it wont work. Gets a: Cannot find method 'Combine(objectHandler, objectHandler)' in 'System.Delegate'

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Funny... I don't see you defining a Combine method in any of your code there... RageInTheMachine9532 "...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome

          C 1 Reply Last reply
          0
          • D Dave Kreskowiak

            First, this forum is for C#, not J#. *** Note to Admins: We need to create a J# Forum! *** :-D Is your connection class creating the controls? From a design standpoint, it really shouldn't be doing this. It's a connection class, not a GUI class... But if you must, you would have to supply a delegate function on your form for the connection class to call using wheteverFormName.Invoke(). This function would then have to create the new controls. The controls absolutely cannot be created directly by the connection class. RageInTheMachine9532 "...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome

            C Offline
            C Offline
            Christer Claesson
            wrote on last edited by
            #5

            I'm a new C# coder but is forced to work with J# on this single project, and I hate it ;-). Anyhow it did not create the controls, that is what was so strange. But we did use alot of Java code and not any delegates. That have been fixed now, but if you read my other post you see my new annoying error. One step forward two step backwards! ;)

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              Funny... I don't see you defining a Combine method in any of your code there... RageInTheMachine9532 "...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome

              C Offline
              C Offline
              Christer Claesson
              wrote on last edited by
              #6

              But that one already exists in System.Delegate right? Atleast it shows up when I type the . after Delegate, and I follow the constructor(two of them and I use the one with two eventHandlers). Oh well, hungover and forced to code due to deadline. Life sucks:)

              D 1 Reply Last reply
              0
              • C Christer Claesson

                But that one already exists in System.Delegate right? Atleast it shows up when I type the . after Delegate, and I follow the constructor(two of them and I use the one with two eventHandlers). Oh well, hungover and forced to code due to deadline. Life sucks:)

                D Offline
                D Offline
                Dave Kreskowiak
                wrote on last edited by
                #7

                Cenatar wrote: Oh well, hungover and forced to code due to deadline. Life sucks Whoa... Dude... A little 'Chaser' next time! :-D Deadlines! Remember?! I should have gone back and read the sample code with both eyes open! Hmmm... OK. This may seem stupid, but did you put this at the top of the code?

                import System.*

                RageInTheMachine9532 "...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome

                C 1 Reply Last reply
                0
                • D Dave Kreskowiak

                  Cenatar wrote: Oh well, hungover and forced to code due to deadline. Life sucks Whoa... Dude... A little 'Chaser' next time! :-D Deadlines! Remember?! I should have gone back and read the sample code with both eyes open! Hmmm... OK. This may seem stupid, but did you put this at the top of the code?

                  import System.*

                  RageInTheMachine9532 "...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome

                  C Offline
                  C Offline
                  Christer Claesson
                  wrote on last edited by
                  #8

                  Ok, yes I'm stupid and cannot read examples clearly :) You need to have a /**@delegate*/ over the delegate deklaration. Odd in my opinion, oh well.

                  D 1 Reply Last reply
                  0
                  • C Christer Claesson

                    Ok, yes I'm stupid and cannot read examples clearly :) You need to have a /**@delegate*/ over the delegate deklaration. Odd in my opinion, oh well.

                    D Offline
                    D Offline
                    Dave Kreskowiak
                    wrote on last edited by
                    #9

                    :wtf::omg::eek::wtf::omg: I already hate J# and I've never written anything in it... RageInTheMachine9532 "...a pungent, gastly, stinky piece of cheese!" -- The Roaming Gnome

                    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