473,756 Members | 7,019 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Object initialization in C# thread - unexplained behaviour

Hello all,

I have a C# class (in this example, called A) that, in its
constructor, starts a thread with a method of its own. That thread
will be used to continuously check for one of its object's state and
generate classe's A events "Connected" and "Disconnect ed".

It looks something like this:

"
public class A
{
private AnotherObject an_obj;
private Thread thr;
...

public event System.EventHan dler Connected;
public event System.EventHan dler Disconnected;

public A()
{
thr = new Thread(new ThreadStart(thi s.DoThreadWork) );
thr.Start();
while (!thr.IsAlive);
thr.IsBackgroun d = true;
}

private void DoThreadWork()
{
an_obj = new AnotherObject() ;

while(true)
{
if (an_obj.IsPrese nt())
if (Connected != null)
Connected(this, EventArgs.Empty );
else
if (Disconnected != null)
Disconnected(th is, EventArgs.Empty );
}
}

public void DoSomethingX()
{
an_obj.CallXWor k();
}

public int DoSomethingY()
{
return an_obj.CallYWor k();
}
}
"

and a form that uses the previous class:

"
public class Form1: System.Windows. Forms.Form
{
private A objA;
...

public Form1()
{
objA = new SmartcardEVCont roller();

objA.Connected += new EventHandler(ob jA_Connected);
objA.Disconnect ed += new EventHandler(ob jA_Disconnected );
}

private void objA_Connected( object sender, EventArgs e)
{
objA.DoSomethin gX();
}

private void objA_Disconnect ed(object sender, EventArgs e)
{
int i = objA.DoSomethin gY();
MessageBox.Show ("Value: " + i);
}

private void button1_Click(o bject sender, System.EventArg s e)
{
objA.DoSomethin gX();
MessageBox.Show ("Done");
}
}
"
The problem is that although every call made to object "objA", inside
the "objA_Connected " or "objA_Disconnec ted" captured event works
perfectly fine, when a method is called on "objA" anywhere else it
just blocks the program execution. In this example, when button1 is
clicked, the instruction "MessageBox.Sho w("Done");" won't get called
and the program (Form1) will stop responding.

By the way, class AnotherObj is a .NET wrapper for a C dll that, in
turn, is a JNI wrapper for a Java class. All Java methods are
"synchroniz ed".

I thought that this could be a problem of the Java object but the fact
is that the cycle inside the thread keeps on executing when calls are
made inside "objA_Connected " or "objA_Disconnec ted" and those calls
execute successfully, no matter how many calls are made to object
"objA".
A strange thing that happens is that the call "objA.DoSomethi ngX();"
inside the click event makes the corresponding Java method start
executing (using log utilities in Java, I can check that the method
began execution but then stopped for no apparent reason).

The only thing I can now think of is that the thread that is spawned
in the A class has some kind of own memory space that the object that
was initialized inside the thread ("an_obj") can't be safely used
outside the thread. Being the thread that generates the events
"Connected" and "Disconnect ed", that could explain that calls to
object "objA", inside "objA_Connected " and "objA_Disconnec ted",
executed well. But that's only an hipothetical thought.

p.s.: I also tried initializing object "an_obj" outside the thread, in
classe's A contructor, but that way the call "an_obj.IsPrese nt())"
would also block in the C dll (that calls JNI code) for no apparent
reason.

If anyone could give me an explanation of why this is happening and
what I can do to avoid it, I would be grateful, as I can't figure it
out just by myself.

Thank you very much,
Ricardo Pereira
Nov 16 '05 #1
12 2328
Ricardo,

To me, it seems that the problem is arising from the fact that your
event is coming in on a separate thread, which then tries to access windows
elements outside of the thread that they were created in. When you call the
static Show method on the MessageBox class, it is not on the main UI thread.
In order to marshal the call to the correct thread, you need to call the
Invoke method on a control that is created on the UI thread (your form would
be fine). You then pass a delegate pointing to the method to be called on
the UI thread, along with any parameters that are needed.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ricardo Pereira" <pe*********@ma il.telepac.pt> wrote in message
news:f1******** *************** **@posting.goog le.com...
Hello all,

I have a C# class (in this example, called A) that, in its
constructor, starts a thread with a method of its own. That thread
will be used to continuously check for one of its object's state and
generate classe's A events "Connected" and "Disconnect ed".

It looks something like this:

"
public class A
{
private AnotherObject an_obj;
private Thread thr;
...

public event System.EventHan dler Connected;
public event System.EventHan dler Disconnected;

public A()
{
thr = new Thread(new ThreadStart(thi s.DoThreadWork) );
thr.Start();
while (!thr.IsAlive);
thr.IsBackgroun d = true;
}

private void DoThreadWork()
{
an_obj = new AnotherObject() ;

while(true)
{
if (an_obj.IsPrese nt())
if (Connected != null)
Connected(this, EventArgs.Empty );
else
if (Disconnected != null)
Disconnected(th is, EventArgs.Empty );
}
}

public void DoSomethingX()
{
an_obj.CallXWor k();
}

public int DoSomethingY()
{
return an_obj.CallYWor k();
}
}
"

and a form that uses the previous class:

"
public class Form1: System.Windows. Forms.Form
{
private A objA;
...

public Form1()
{
objA = new SmartcardEVCont roller();

objA.Connected += new EventHandler(ob jA_Connected);
objA.Disconnect ed += new EventHandler(ob jA_Disconnected );
}

private void objA_Connected( object sender, EventArgs e)
{
objA.DoSomethin gX();
}

private void objA_Disconnect ed(object sender, EventArgs e)
{
int i = objA.DoSomethin gY();
MessageBox.Show ("Value: " + i);
}

private void button1_Click(o bject sender, System.EventArg s e)
{
objA.DoSomethin gX();
MessageBox.Show ("Done");
}
}
"
The problem is that although every call made to object "objA", inside
the "objA_Connected " or "objA_Disconnec ted" captured event works
perfectly fine, when a method is called on "objA" anywhere else it
just blocks the program execution. In this example, when button1 is
clicked, the instruction "MessageBox.Sho w("Done");" won't get called
and the program (Form1) will stop responding.

By the way, class AnotherObj is a .NET wrapper for a C dll that, in
turn, is a JNI wrapper for a Java class. All Java methods are
"synchroniz ed".

I thought that this could be a problem of the Java object but the fact
is that the cycle inside the thread keeps on executing when calls are
made inside "objA_Connected " or "objA_Disconnec ted" and those calls
execute successfully, no matter how many calls are made to object
"objA".
A strange thing that happens is that the call "objA.DoSomethi ngX();"
inside the click event makes the corresponding Java method start
executing (using log utilities in Java, I can check that the method
began execution but then stopped for no apparent reason).

The only thing I can now think of is that the thread that is spawned
in the A class has some kind of own memory space that the object that
was initialized inside the thread ("an_obj") can't be safely used
outside the thread. Being the thread that generates the events
"Connected" and "Disconnect ed", that could explain that calls to
object "objA", inside "objA_Connected " and "objA_Disconnec ted",
executed well. But that's only an hipothetical thought.

p.s.: I also tried initializing object "an_obj" outside the thread, in
classe's A contructor, but that way the call "an_obj.IsPrese nt())"
would also block in the C dll (that calls JNI code) for no apparent
reason.

If anyone could give me an explanation of why this is happening and
what I can do to avoid it, I would be grateful, as I can't figure it
out just by myself.

Thank you very much,
Ricardo Pereira

Nov 16 '05 #2
Ricardo Pereira <pe*********@ma il.telepac.pt> wrote:

<snip>
If anyone could give me an explanation of why this is happening and
what I can do to avoid it, I would be grateful, as I can't figure it
out just by myself.


Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

Cut out all the Java stuff and just give some bare-bones .NET-only code
which shows the problem.

By the way, the line

while (!thr.IsAlive) ;

is a pretty nasty way of waiting for the thread to start - a
Thread.Sleep call in the loop would at least stop it from being *quite*
such a tight loop.

(I'm not sure why you're waiting for it to start before making it a
background thread anyway, to be honest.)

Similarly, I hope an_obj.IsPresen t() is waiting or sleeping or
something similar, otherwise you've got another potentially tight loop
there - never a good idea.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #3
Hi Ricardo:

The following line of code in class A's constructor is putting the
calling thread into an infinite loop:

while (!thr.IsAlive);

Because the thread you are creating (thr) is also in an infinite
while(true) loop.

The thread calling the constructor on A is the user interface thread,
you won't see the form refresh or react to events until the thread is
free to process those events.

Polling the outside object to generate the connect and disconnect
events will in this fashion will be very expensive. Are there any
events on the AnotherObject object you can subscribe to? It's hard to
tell what you need to accomplish but somehow I think invoking
CallXWork infinitely is not what you want to do.

--
Scott
http://www.OdeToCode.com
On 31 May 2004 11:13:08 -0700, pe*********@mai l.telepac.pt (Ricardo
Pereira) wrote:
Hello all,

I have a C# class (in this example, called A) that, in its
constructor, starts a thread with a method of its own. That thread
will be used to continuously check for one of its object's state and
generate classe's A events "Connected" and "Disconnect ed".

It looks something like this:

"
public class A
{
private AnotherObject an_obj;
private Thread thr;
...

public event System.EventHan dler Connected;
public event System.EventHan dler Disconnected;

public A()
{
thr = new Thread(new ThreadStart(thi s.DoThreadWork) );
thr.Start();
while (!thr.IsAlive);
thr.IsBackgroun d = true;
}

private void DoThreadWork()
{
an_obj = new AnotherObject() ;

while(true)
{
if (an_obj.IsPrese nt())
if (Connected != null)
Connected(this, EventArgs.Empty );
else
if (Disconnected != null)
Disconnected(th is, EventArgs.Empty );
}
}

public void DoSomethingX()
{
an_obj.CallXWor k();
}

public int DoSomethingY()
{
return an_obj.CallYWor k();
}
}
"

and a form that uses the previous class:

"
public class Form1: System.Windows. Forms.Form
{
private A objA;
...

public Form1()
{
objA = new SmartcardEVCont roller();

objA.Connected += new EventHandler(ob jA_Connected);
objA.Disconnect ed += new EventHandler(ob jA_Disconnected );
}

private void objA_Connected( object sender, EventArgs e)
{
objA.DoSomethin gX();
}

private void objA_Disconnect ed(object sender, EventArgs e)
{
int i = objA.DoSomethin gY();
MessageBox.Show ("Value: " + i);
}

private void button1_Click(o bject sender, System.EventArg s e)
{
objA.DoSomethin gX();
MessageBox.Show ("Done");
}
}
"
The problem is that although every call made to object "objA", inside
the "objA_Connected " or "objA_Disconnec ted" captured event works
perfectly fine, when a method is called on "objA" anywhere else it
just blocks the program execution. In this example, when button1 is
clicked, the instruction "MessageBox.Sho w("Done");" won't get called
and the program (Form1) will stop responding.

By the way, class AnotherObj is a .NET wrapper for a C dll that, in
turn, is a JNI wrapper for a Java class. All Java methods are
"synchronized" .

I thought that this could be a problem of the Java object but the fact
is that the cycle inside the thread keeps on executing when calls are
made inside "objA_Connected " or "objA_Disconnec ted" and those calls
execute successfully, no matter how many calls are made to object
"objA".
A strange thing that happens is that the call "objA.DoSomethi ngX();"
inside the click event makes the corresponding Java method start
executing (using log utilities in Java, I can check that the method
began execution but then stopped for no apparent reason).

The only thing I can now think of is that the thread that is spawned
in the A class has some kind of own memory space that the object that
was initialized inside the thread ("an_obj") can't be safely used
outside the thread. Being the thread that generates the events
"Connected" and "Disconnect ed", that could explain that calls to
object "objA", inside "objA_Connected " and "objA_Disconnec ted",
executed well. But that's only an hipothetical thought.

p.s.: I also tried initializing object "an_obj" outside the thread, in
classe's A contructor, but that way the call "an_obj.IsPrese nt())"
would also block in the C dll (that calls JNI code) for no apparent
reason.

If anyone could give me an explanation of why this is happening and
what I can do to avoid it, I would be grateful, as I can't figure it
out just by myself.

Thank you very much,
Ricardo Pereira


Nov 16 '05 #4
Scott Allen <bitmask@[nospam].fred.net> wrote:
The following line of code in class A's constructor is putting the
calling thread into an infinite loop:

while (!thr.IsAlive);

Because the thread you are creating (thr) is also in an infinite
while(true) loop.


Nope - while (!thr.IsAlive); is just waiting for the thread to actually
start. It's not a good idea, but it's not actually an infinite loop.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5
Hi Ricardo,

I IMHO the probelm is not in the that class. The probem is in the C dll or
Java code.
I can't say why it doesn't work, but I dare to say the problem is not in
this code.

For example AnotherObject class can be thread sensitive just like Control
classes are. Even it can use windows controls itself.

In this case the an_obj is created inside the new worker thread. When you
call from within the event handlers you call the method in the context of
the thread created the object.
When call it form the button click you call the an_obj's method not from the
thread created the object. If an_obj uses UI contrlos it may block.
Try to move
an_obj = new AnotherObject() ;
from DoThreadWork to the constructor. See if it behaves in the same way.
As a matter of fact threads do have local thread storage, but as far as I
can see this code doesn't use it.

--

Stoitcho Goutsev (100) [C# MVP]
"Ricardo Pereira" <pe*********@ma il.telepac.pt> wrote in message
news:f1******** *************** **@posting.goog le.com...
Hello all,

I have a C# class (in this example, called A) that, in its
constructor, starts a thread with a method of its own. That thread
will be used to continuously check for one of its object's state and
generate classe's A events "Connected" and "Disconnect ed".

It looks something like this:

"
public class A
{
private AnotherObject an_obj;
private Thread thr;
...

public event System.EventHan dler Connected;
public event System.EventHan dler Disconnected;

public A()
{
thr = new Thread(new ThreadStart(thi s.DoThreadWork) );
thr.Start();
while (!thr.IsAlive);
thr.IsBackgroun d = true;
}

private void DoThreadWork()
{
an_obj = new AnotherObject() ;

while(true)
{
if (an_obj.IsPrese nt())
if (Connected != null)
Connected(this, EventArgs.Empty );
else
if (Disconnected != null)
Disconnected(th is, EventArgs.Empty );
}
}

public void DoSomethingX()
{
an_obj.CallXWor k();
}

public int DoSomethingY()
{
return an_obj.CallYWor k();
}
}
"

and a form that uses the previous class:

"
public class Form1: System.Windows. Forms.Form
{
private A objA;
...

public Form1()
{
objA = new SmartcardEVCont roller();

objA.Connected += new EventHandler(ob jA_Connected);
objA.Disconnect ed += new EventHandler(ob jA_Disconnected );
}

private void objA_Connected( object sender, EventArgs e)
{
objA.DoSomethin gX();
}

private void objA_Disconnect ed(object sender, EventArgs e)
{
int i = objA.DoSomethin gY();
MessageBox.Show ("Value: " + i);
}

private void button1_Click(o bject sender, System.EventArg s e)
{
objA.DoSomethin gX();
MessageBox.Show ("Done");
}
}
"
The problem is that although every call made to object "objA", inside
the "objA_Connected " or "objA_Disconnec ted" captured event works
perfectly fine, when a method is called on "objA" anywhere else it
just blocks the program execution. In this example, when button1 is
clicked, the instruction "MessageBox.Sho w("Done");" won't get called
and the program (Form1) will stop responding.

By the way, class AnotherObj is a .NET wrapper for a C dll that, in
turn, is a JNI wrapper for a Java class. All Java methods are
"synchroniz ed".

I thought that this could be a problem of the Java object but the fact
is that the cycle inside the thread keeps on executing when calls are
made inside "objA_Connected " or "objA_Disconnec ted" and those calls
execute successfully, no matter how many calls are made to object
"objA".
A strange thing that happens is that the call "objA.DoSomethi ngX();"
inside the click event makes the corresponding Java method start
executing (using log utilities in Java, I can check that the method
began execution but then stopped for no apparent reason).

The only thing I can now think of is that the thread that is spawned
in the A class has some kind of own memory space that the object that
was initialized inside the thread ("an_obj") can't be safely used
outside the thread. Being the thread that generates the events
"Connected" and "Disconnect ed", that could explain that calls to
object "objA", inside "objA_Connected " and "objA_Disconnec ted",
executed well. But that's only an hipothetical thought.

p.s.: I also tried initializing object "an_obj" outside the thread, in
classe's A contructor, but that way the call "an_obj.IsPrese nt())"
would also block in the C dll (that calls JNI code) for no apparent
reason.

If anyone could give me an explanation of why this is happening and
what I can do to avoid it, I would be grateful, as I can't figure it
out just by myself.

Thank you very much,
Ricardo Pereira

Nov 16 '05 #6
Hi Nicholas,

AFAIK you can call MessageBox.Show . from any thread.

--

Stoitcho Goutsev (100) [C# MVP]
"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard .caspershouse.c om> wrote in
message news:eF******** *****@TK2MSFTNG P10.phx.gbl...
Ricardo,

To me, it seems that the problem is arising from the fact that your
event is coming in on a separate thread, which then tries to access windows elements outside of the thread that they were created in. When you call the static Show method on the MessageBox class, it is not on the main UI thread. In order to marshal the call to the correct thread, you need to call the
Invoke method on a control that is created on the UI thread (your form would be fine). You then pass a delegate pointing to the method to be called on
the UI thread, along with any parameters that are needed.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Ricardo Pereira" <pe*********@ma il.telepac.pt> wrote in message
news:f1******** *************** **@posting.goog le.com...
Hello all,

I have a C# class (in this example, called A) that, in its
constructor, starts a thread with a method of its own. That thread
will be used to continuously check for one of its object's state and
generate classe's A events "Connected" and "Disconnect ed".

It looks something like this:

"
public class A
{
private AnotherObject an_obj;
private Thread thr;
...

public event System.EventHan dler Connected;
public event System.EventHan dler Disconnected;

public A()
{
thr = new Thread(new ThreadStart(thi s.DoThreadWork) );
thr.Start();
while (!thr.IsAlive);
thr.IsBackgroun d = true;
}

private void DoThreadWork()
{
an_obj = new AnotherObject() ;

while(true)
{
if (an_obj.IsPrese nt())
if (Connected != null)
Connected(this, EventArgs.Empty );
else
if (Disconnected != null)
Disconnected(th is, EventArgs.Empty );
}
}

public void DoSomethingX()
{
an_obj.CallXWor k();
}

public int DoSomethingY()
{
return an_obj.CallYWor k();
}
}
"

and a form that uses the previous class:

"
public class Form1: System.Windows. Forms.Form
{
private A objA;
...

public Form1()
{
objA = new SmartcardEVCont roller();

objA.Connected += new EventHandler(ob jA_Connected);
objA.Disconnect ed += new EventHandler(ob jA_Disconnected );
}

private void objA_Connected( object sender, EventArgs e)
{
objA.DoSomethin gX();
}

private void objA_Disconnect ed(object sender, EventArgs e)
{
int i = objA.DoSomethin gY();
MessageBox.Show ("Value: " + i);
}

private void button1_Click(o bject sender, System.EventArg s e)
{
objA.DoSomethin gX();
MessageBox.Show ("Done");
}
}
"
The problem is that although every call made to object "objA", inside
the "objA_Connected " or "objA_Disconnec ted" captured event works
perfectly fine, when a method is called on "objA" anywhere else it
just blocks the program execution. In this example, when button1 is
clicked, the instruction "MessageBox.Sho w("Done");" won't get called
and the program (Form1) will stop responding.

By the way, class AnotherObj is a .NET wrapper for a C dll that, in
turn, is a JNI wrapper for a Java class. All Java methods are
"synchroniz ed".

I thought that this could be a problem of the Java object but the fact
is that the cycle inside the thread keeps on executing when calls are
made inside "objA_Connected " or "objA_Disconnec ted" and those calls
execute successfully, no matter how many calls are made to object
"objA".
A strange thing that happens is that the call "objA.DoSomethi ngX();"
inside the click event makes the corresponding Java method start
executing (using log utilities in Java, I can check that the method
began execution but then stopped for no apparent reason).

The only thing I can now think of is that the thread that is spawned
in the A class has some kind of own memory space that the object that
was initialized inside the thread ("an_obj") can't be safely used
outside the thread. Being the thread that generates the events
"Connected" and "Disconnect ed", that could explain that calls to
object "objA", inside "objA_Connected " and "objA_Disconnec ted",
executed well. But that's only an hipothetical thought.

p.s.: I also tried initializing object "an_obj" outside the thread, in
classe's A contructor, but that way the call "an_obj.IsPrese nt())"
would also block in the C dll (that calls JNI code) for no apparent
reason.

If anyone could give me an explanation of why this is happening and
what I can do to avoid it, I would be grateful, as I can't figure it
out just by myself.

Thank you very much,
Ricardo Pereira


Nov 16 '05 #7
Oops, missed the negation operator.

On Mon, 31 May 2004 19:48:51 +0100, Jon Skeet [C# MVP]
<sk***@pobox.co m> wrote:
Scott Allen <bitmask@[nospam].fred.net> wrote:
The following line of code in class A's constructor is putting the
calling thread into an infinite loop:

while (!thr.IsAlive);

Because the thread you are creating (thr) is also in an infinite
while(true) loop.


Nope - while (!thr.IsAlive); is just waiting for the thread to actually
start. It's not a good idea, but it's not actually an infinite loop.


--
Scott
http://www.OdeToCode.com
Nov 16 '05 #8
Hi and thank you all for your tips.

It seems that the problem did have something to do with the fact that
some of the code from the DLL (the one that calls JNI code) was being
called from the spawned thread and some other was being called from
the main thread, and JNI blocked somewhere (probably looking for some
resources that were only availabe in the initial thread).

This got resolved by implementing a COM object instead of the regular
DLL, for the reason that this COM object can end up running everything
in a single thread, which solves the problem.
Thanks again for everyone.
Ricardo Pereira
Nov 16 '05 #9
"Ricardo Pereira" <pe*********@ma il.telepac.pt> wrote in message
news:f1******** *************** **@posting.goog le.com...
Hello all,

I have a C# class (in this example, called A) that, in its
constructor, starts a thread with a method of its own. That thread
will be used to continuously check for one of its object's state and
generate classe's A events "Connected" and "Disconnect ed".

It looks something like this: [...] public A()
{
thr = new Thread(new ThreadStart(thi s.DoThreadWork) );
thr.Start();
while (!thr.IsAlive);
thr.IsBackgroun d = true;
}

[...]

It is better not to poll like you do in the while loop. It is better to use
a ManualResetEven t object and wait (WaitHandle.Wai tOne) on it for the thread
to come alive. Let the thread you start signal the event when it starts
(ManualResetEve nt.Set).

Cheers,
---
Tom Tempelaere
Nov 16 '05 #10

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

Similar topics

106
5588
by: A | last post by:
Hi, I have always been taught to use an inialization list for initialising data members of a class. I realize that initialsizing primitives and pointers use an inialization list is exactly the same as an assignment, but for class types it has a different effect - it calls the copy constructor. My question is when to not use an initalisation list for initialising data members of a class?
2
2979
by: Ryan Mitchley | last post by:
Hi all I have code for an object factory, heavily based on an article by Jim Hyslop (although I've made minor modifications). The factory was working fine using g++, but since switching to the Intel compiler it has stopped working. I think the singleton pattern static instance thing may be at the root of the problem, but I'm not sure. I had to add calls to instance() in regCreateFn, which gets the behaviour more in line with what I was...
4
2673
by: Cheng Mo | last post by:
I know global varaibles should always be avoided. I asked this question just for deep insight about C++. If global variables are distributed among different source code files, what's the initialziation sequence of these varaibles. Say, Foo g_fooMain in main.cpp; Foo g_hello in hello.cpp; Foo g_bye in bye.cpp; and main.cpp has code #include "hello.h"
8
1840
by: Mark Neilson | last post by:
1. What is the best way to make a single instance of my top level class (DLL) internally available to all other members of the assembly? The top level object is where all other access is made in to the program. Where and how do I declare and initialise this object? For instance, it would have property implementation like this: //******************************************* public MyClass1 Class1 {
4
5021
by: 6tc1 | last post by:
Hi all, I have just finished debugging a windows application and have solved the problem - however, I want to be sure that I understand the problem before I move on. Before I detail the problem, this problem requires some understanding of threading concepts. Basically, the class contained both a PictureBox object as well as a corresponding Image object (they both had a copy of the same picture). The following was used to access the...
26
5694
by: yb | last post by:
Hi, Is there a standard for the global 'window' object in browsers? For example, it supports methods such as setInterval and clearInterval, and several others. I know that w3c standardized several parts of the DOM, but this does not include the window object. Thank you
1
4243
by: philwozza | last post by:
Hi I have a THREAD class that uses the static variable NextThreadID to store the id of the next thread to be created and a static Mutex to protect it. class THREAD { public: int Start(void); private: unsigned int ThreadID;
9
2472
by: ziman137 | last post by:
Hi all, The results from following codes got me a bit confused. #include <stdio.h> #include <iostream> using namespace std; struct A {
23
3146
by: tonytech08 | last post by:
What I like about the C++ object model: that the data portion of the class IS the object (dereferencing an object gets you the data of a POD object). What I don't like about the C++ object model: that most OO features are not available for class object design without loss of POD-ness. So, I'm more than leaning toward "bad" because of the limitations and
0
9456
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9275
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10040
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9873
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9846
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9713
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7248
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6534
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
3
2666
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.