473,473 Members | 2,028 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Object with callback destroyed ??

Hello,

I have a project like that :
.....
TestClass t;
for (i=1;i<=x;i++)
{
t=new TestClass(params);
t.Save();
}
....

In the constructor of TestClass, if params has a particular value, I create
a TCPClient, connect it to a serveur, and run a (asynch) beginread.
When a read some data, I resend some other , ...
If all is good, the dialog is max 2-3 second long
My question :
Is that good ?
when I write t=new ..., I think I lost the reference to the precedent
constructed class, so what with the asynch callback? it's destructed and
never called ?

And if i'm wrong, what is the best solution to correct that ?
The for() is for example? Normaly it's data readed from a stream (serialport
or TCP/IP), and I must create class taht represent Event readed.

Thx

Mar 31 '06 #1
3 1531
Do you want to wait for the old instance of TestClass to complete? Then you
should use an AutoResetEvent, call WaitOne before instantiating new
TestClass, and Set after the operation is complete.
If you don't intend to wait for the operation to complete, you should keep
references to all TestClasses you've instantiated in a simple
List<TestClass>, for example.

"Geoffrey" <AE**************@dufour.be> wrote in message
news:uc**************@tk2msftngp13.phx.gbl...
Hello,

I have a project like that :
....
TestClass t;
for (i=1;i<=x;i++)
{
t=new TestClass(params);
t.Save();
}
...

In the constructor of TestClass, if params has a particular value, I
create
a TCPClient, connect it to a serveur, and run a (asynch) beginread.
When a read some data, I resend some other , ...
If all is good, the dialog is max 2-3 second long
My question :
Is that good ?
when I write t=new ..., I think I lost the reference to the precedent
constructed class, so what with the asynch callback? it's destructed and
never called ?

And if i'm wrong, what is the best solution to correct that ?
The for() is for example? Normaly it's data readed from a stream
(serialport
or TCP/IP), and I must create class taht represent Event readed.

Thx

Mar 31 '06 #2
No, I don't want to wait to complete.

I wan't to be sure that all the TCP/IP communicatie are good completed.
So, I think I have to keep all references or make my tcp/ip communicatie
synchronous ...

And what if in testclass, I create a class ClassCommunicatie with a function
start.
And call this function in a ThreadStart() ?

"Lebesgue" <no****@spam.jp> a écrit dans le message de
news:Oz**************@TK2MSFTNGP10.phx.gbl...
Do you want to wait for the old instance of TestClass to complete? Then you should use an AutoResetEvent, call WaitOne before instantiating new
TestClass, and Set after the operation is complete.
If you don't intend to wait for the operation to complete, you should keep
references to all TestClasses you've instantiated in a simple
List<TestClass>, for example.

"Geoffrey" <AE**************@dufour.be> wrote in message
news:uc**************@tk2msftngp13.phx.gbl...
Hello,

I have a project like that :
....
TestClass t;
for (i=1;i<=x;i++)
{
t=new TestClass(params);
t.Save();
}
...

In the constructor of TestClass, if params has a particular value, I
create
a TCPClient, connect it to a serveur, and run a (asynch) beginread.
When a read some data, I resend some other , ...
If all is good, the dialog is max 2-3 second long
My question :
Is that good ?
when I write t=new ..., I think I lost the reference to the precedent
constructed class, so what with the asynch callback? it's destructed and
never called ?

And if i'm wrong, what is the best solution to correct that ?
The for() is for example? Normaly it's data readed from a stream
(serialport
or TCP/IP), and I must create class taht represent Event readed.

Thx


Mar 31 '06 #3
No, I don't want to wait to complete.

I wan't to be sure that all the TCP/IP communicatie are good completed.
So, I think I have to keep all references or make my tcp/ip communicatie
synchronous ...

And what if in testclass, I create a class ClassCommunicatie with a function
start.
And call this function in a ThreadStart() ?

"Lebesgue" <no****@spam.jp> a écrit dans le message de
news:Oz**************@TK2MSFTNGP10.phx.gbl...
Do you want to wait for the old instance of TestClass to complete? Then you should use an AutoResetEvent, call WaitOne before instantiating new
TestClass, and Set after the operation is complete.
If you don't intend to wait for the operation to complete, you should keep
references to all TestClasses you've instantiated in a simple
List<TestClass>, for example.

"Geoffrey" <AE**************@dufour.be> wrote in message
news:uc**************@tk2msftngp13.phx.gbl...
Hello,

I have a project like that :
....
TestClass t;
for (i=1;i<=x;i++)
{
t=new TestClass(params);
t.Save();
}
...

In the constructor of TestClass, if params has a particular value, I
create
a TCPClient, connect it to a serveur, and run a (asynch) beginread.
When a read some data, I resend some other , ...
If all is good, the dialog is max 2-3 second long
My question :
Is that good ?
when I write t=new ..., I think I lost the reference to the precedent
constructed class, so what with the asynch callback? it's destructed and
never called ?

And if i'm wrong, what is the best solution to correct that ?
The for() is for example? Normaly it's data readed from a stream
(serialport
or TCP/IP), and I must create class taht represent Event readed.

Thx


Apr 3 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Nick Jacobson | last post by:
Casting an 'enumerate' object destroys it?? Is that supposed to happen, or is it a bug? For example: a = e = enumerate(a) print dict(e) print dict(e)
7
by: Martin | last post by:
Bit of a newbie question here (I'm familiar with OO in general, just not in C++ yet). I've seen code example where the general syntax for creating a new object is as follows: Thing a = new...
11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
4
by: Zork | last post by:
Hi, I am trying to stop object creation (in this case ill use a ball as the object) via use of exceptions. In essence, if the ball does not have an owner, I do not want the ball object created....
12
by: Olumide | last post by:
I'm studying Nigel Chapman's Late Night Guide to C++ which I think is an absolutely fantastic book; however on page 175 (topic: operator overlaoding), there the following code snippet: inline...
2
by: MR | last post by:
help! I have an unmanaged DLL that I do not have the source code, so i can't recompile or make changes. the DLL requires a callback function. I would like to implement the callback method in a...
2
by: Chewie2112 | last post by:
Is there a way in VB to get a notification when an object is destroyed when that object does not have a terminate event? I am using a control that does not have a notification event when it is...
10
by: Jess | last post by:
Hello, If I create a temporary object using a dynamically created object's pointer, then when the temporary object is destroyed, will the dynamically created object be destroyed too? My guess...
3
Dormilich
by: Dormilich | last post by:
recently I came over a piece of code where this question arose. scenarion: a new object is created locally in a class's method, but when will this object be destroyed? (ok, at latest at script...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.