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
  1. Home
  2. General Programming
  3. Windows Forms
  4. Help ! "Object in use elsewhere,,,," exception

Help ! "Object in use elsewhere,,,," exception

Scheduled Pinned Locked Moved Windows Forms
6 Posts 2 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.
  • V Offline
    V Offline
    Vivek_India
    wrote on last edited by
    #1

    hi everyone, Hope everyone's doing better than me... I have a problem Here's the scenario i'm currently a Network App using the Socket Class which sends the image over the network.. Client Sends the image the image is basicaly wrapped in my Packet class in packet assembly (ofcource both the sides (client/server) will have reference to it).. so i serialize it and send it through the networkstream of the socket this happens on a separate thread.. like so

    .................
    'some where in the form
    dim thre as new THread(addressof (startstream)
    thre.start()

    .............
    'thread procedure
    Sub startstream
    dim img as bitmap
    mypacket.screen=img
    formatter.serialize(stream,mypacket)
    End Sub

    where 'mypacket' is a instance of Packet class Server recieves the image and deserialize it and uses it... this also happens on a separate thread.. my idea is to send and recieve the packet(containing the image) asynchronously using threads is that a bad idea..or is there something fundamentally wrong... The exception is Object in use elsewhere...on the client side serializing.. what am iam doing wrong here.. can anyone help me.. please forgive me, if my question sounds stupid and cause i'm a newbie thanks in advance..

    L 1 Reply Last reply
    0
    • V Vivek_India

      hi everyone, Hope everyone's doing better than me... I have a problem Here's the scenario i'm currently a Network App using the Socket Class which sends the image over the network.. Client Sends the image the image is basicaly wrapped in my Packet class in packet assembly (ofcource both the sides (client/server) will have reference to it).. so i serialize it and send it through the networkstream of the socket this happens on a separate thread.. like so

      .................
      'some where in the form
      dim thre as new THread(addressof (startstream)
      thre.start()

      .............
      'thread procedure
      Sub startstream
      dim img as bitmap
      mypacket.screen=img
      formatter.serialize(stream,mypacket)
      End Sub

      where 'mypacket' is a instance of Packet class Server recieves the image and deserialize it and uses it... this also happens on a separate thread.. my idea is to send and recieve the packet(containing the image) asynchronously using threads is that a bad idea..or is there something fundamentally wrong... The exception is Object in use elsewhere...on the client side serializing.. what am iam doing wrong here.. can anyone help me.. please forgive me, if my question sounds stupid and cause i'm a newbie thanks in advance..

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Vivek_India wrote:

      what am iam doing wrong here

      Vivek_India wrote:

      cause i'm a newbie

      You are engaged in far to complex a project for a newb. Studying materials designed to introduce and teach a subject to beginners is what you should be doing, rather than coding and posting messages in internet forums.

      V 1 Reply Last reply
      0
      • L led mike

        Vivek_India wrote:

        what am iam doing wrong here

        Vivek_India wrote:

        cause i'm a newbie

        You are engaged in far to complex a project for a newb. Studying materials designed to introduce and teach a subject to beginners is what you should be doing, rather than coding and posting messages in internet forums.

        V Offline
        V Offline
        Vivek_India
        wrote on last edited by
        #3

        k.. i may not be an exact newbie ...but i am new to Multi-threading..i learned all the theory about it ..but the implementation went haywire.. so i thought of asking here..its wrong is it... and sorry if it offended you.... :)

        L 1 Reply Last reply
        0
        • V Vivek_India

          k.. i may not be an exact newbie ...but i am new to Multi-threading..i learned all the theory about it ..but the implementation went haywire.. so i thought of asking here..its wrong is it... and sorry if it offended you.... :)

          L Offline
          L Offline
          led mike
          wrote on last edited by
          #4

          Vivek_India wrote:

          sorry if it offended you

          In western culture, there is nothing in my post indicating I was offended, because I was not, I am simply offering free advice. You are not obligated to take it.

          Vivek_India wrote:

          so i thought of asking here..its wrong is it...

          Not wrong, just not optimal for beginners. Materials have already been design to teach beginners in these subjects and using them would be far more productive than internet forums for learning a subject. The forums are great for specific focused discussions, not so much for large subjects. Multi-threading is a very large subject.

          Vivek_India wrote:

          .i learned all the theory about it

          Back when I started I found the chapters in Advanced Windows[^] on multi-threading to be very helpful.

          V 1 Reply Last reply
          0
          • L led mike

            Vivek_India wrote:

            sorry if it offended you

            In western culture, there is nothing in my post indicating I was offended, because I was not, I am simply offering free advice. You are not obligated to take it.

            Vivek_India wrote:

            so i thought of asking here..its wrong is it...

            Not wrong, just not optimal for beginners. Materials have already been design to teach beginners in these subjects and using them would be far more productive than internet forums for learning a subject. The forums are great for specific focused discussions, not so much for large subjects. Multi-threading is a very large subject.

            Vivek_India wrote:

            .i learned all the theory about it

            Back when I started I found the chapters in Advanced Windows[^] on multi-threading to be very helpful.

            V Offline
            V Offline
            Vivek_India
            wrote on last edited by
            #5

            Hey thanks ...led-mike And sorry, I completely misunderstood you.. any way i will study the book you recommended( or may be similar text is that ok?)...any way i was wondering what could be wrong and suddenly the part where a bitmap object is assigned to the image property of the Picturebox Picbox.image=screen was causing the trouble.. when i commented it out, it worked fine..i learned that picturebox was being rendered on a different thread,, than mine so it was accoring to VS 2005 illegal cross thread operation or something along that line... is there any thread safe way to do it... And finally my english is not so good, so i apologize for the inconvenience... Thnx and regards Vivek

            L 1 Reply Last reply
            0
            • V Vivek_India

              Hey thanks ...led-mike And sorry, I completely misunderstood you.. any way i will study the book you recommended( or may be similar text is that ok?)...any way i was wondering what could be wrong and suddenly the part where a bitmap object is assigned to the image property of the Picturebox Picbox.image=screen was causing the trouble.. when i commented it out, it worked fine..i learned that picturebox was being rendered on a different thread,, than mine so it was accoring to VS 2005 illegal cross thread operation or something along that line... is there any thread safe way to do it... And finally my english is not so good, so i apologize for the inconvenience... Thnx and regards Vivek

              L Offline
              L Offline
              led mike
              wrote on last edited by
              #6

              Vivek_India wrote:

              is there any thread safe way to do it

              Of course, but once again this is the same issue of you trying to write code for a subject that you have not studied. In my experience, software development does not really work out well using that approach. And as I stated before, posting messages on internet forums is no substitution for putting in the proper effort of studying the subjects. http://www.google.com/search?hl=en&q=MSDN+BeginInvoke&btnG=Google+Search&aq=f&oq=[^]

              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