Help ! "Object in use elsewhere,,,," exception
-
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 Subwhere '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..
-
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 Subwhere '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..
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.
-
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.
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.... :)
-
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.... :)
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.
-
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.
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 -
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 VivekVivek_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=[^]