473,386 Members | 1,810 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

ActiveX control in new thread goes slow

I have an activeX control which I am calling from a C# program, this works
fine.

I now want to call the activeX control from a seperate thread, this works
but is very slow. This is far too slow to work properly, can anyone suggest
how I can fix this?

The program is not doing anything else while the thread is running, the idea
is that the thread will be running continously in a loop to animate the
activeX control. However it runs slow from the start (only when in a
seperate thread) even in its first time through the loop.

I have tried setting the ApartmentState to single threaded or multi threaded
but this make no difference:
Thread t = new Thread (new ThreadStart(a.work));
// t.ApartmentState = ApartmentState.STA; // control is single threaded
t.ApartmentState = ApartmentState.MTA; // control is multi threaded

I have tried setting the priority to Lowest, Normal or Highest but this make
no difference either:
//t.Priority=System.Threading.ThreadPriority.Lowest;
//t.Priority=System.Threading.ThreadPriority.Normal;
t.Priority=System.Threading.ThreadPriority.Highest ;

Information and code for the activeX control I am using is here:
http://www.euclideanspace.com/mjbWor...geSpecific/net
Specific/createATL/

I would appeciate and ideas I can try to fix this, thanks,

Martin

Nov 15 '05 #1
2 4638
Martin,

I suspect that the code in the thread is the culprit, not how you are
setting the thread up.

Can you show the code in the work method on the instance of a?

--
- Nicholas Paldino [.NET/C# MVP]
- ni**************@exisconsulting.com

"Martin Baker" <ba****@btinternet.com> wrote in message
news:bj**********@titan.btinternet.com...
I have an activeX control which I am calling from a C# program, this works
fine.

I now want to call the activeX control from a seperate thread, this works
but is very slow. This is far too slow to work properly, can anyone suggest how I can fix this?

The program is not doing anything else while the thread is running, the idea is that the thread will be running continously in a loop to animate the
activeX control. However it runs slow from the start (only when in a
seperate thread) even in its first time through the loop.

I have tried setting the ApartmentState to single threaded or multi threaded but this make no difference:
Thread t = new Thread (new ThreadStart(a.work));
// t.ApartmentState = ApartmentState.STA; // control is single threaded
t.ApartmentState = ApartmentState.MTA; // control is multi threaded

I have tried setting the priority to Lowest, Normal or Highest but this make no difference either:
//t.Priority=System.Threading.ThreadPriority.Lowest;
//t.Priority=System.Threading.ThreadPriority.Normal;
t.Priority=System.Threading.ThreadPriority.Highest ;

Information and code for the activeX control I am using is here:
http://www.euclideanspace.com/mjbWor...geSpecific/net Specific/createATL/

I would appeciate and ideas I can try to fix this, thanks,

Martin

Nov 15 '05 #2
Nicholas,
Martin,

I suspect that the code in the thread is the culprit, not how you are
setting the thread up.

Can you show the code in the work method on the instance of a?


It is run from the startAnimation() method below.
In order to save your time I have tried to extract the essence here,

namespace mjbWorld {
class animationLoop{
public delegate void Start (object o);
private class Args{
public object o;
public Start s;
public void work(){
s(o);
}
}

public static Thread CreateThread (Start s, Object arg){
Args a = new Args();
a.o = arg;
a.s = s;
Thread t = new Thread (new ThreadStart(a.work));
t.ApartmentState = ApartmentState.STA; // control is single
threaded
// t.ApartmentState = ApartmentState.MTA; // control is multi
threaded
return t;
}
}
}

this is then run from here:

public void startAnimation(){
if(animationThread==null) animationThread =
animationLoop.CreateThread(new animationLoop.Start(this.runAnimation),4);
animationThread.Start();
vc3d.root.timeline((int)(nodeBean.timelineCommand. TIMELINE_START));
}

which runs this:

public void runAnimation(object o) {
bool running=true;
if(animationThread!=null)
animationThread.Priority=System.Threading.ThreadPr iority.Lowest; // I have
tried Normal and Highest, no difference.
do {
vc3d.root.step(0,0);
if (eventNotifyChanged != null) eventNotifyChanged(null,new
mjbEventArgs(0));
} while(running);
}

The eventNotifyChanged method goes down through the scenegraph which
consists of many nodes, and these nodes call methods in the activeX control.
The activeX control is a very thin wrapper for OpenGL, which is written in
C++ and consists of a number of very simple methods like this:

STDMETHODIMP CmjboglCtl::mglVertex3d(DOUBLE x, DOUBLE y, DOUBLE z) {
glVertex3d(x,y,z);
return S_OK;
}

These methods seem to take a very long time to return, but only when called
from the thread.

Thank you for taking the time to look at this,

Martin



Nov 15 '05 #3

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

Similar topics

1
by: Marwan | last post by:
Hello I am using asynchronous delegates to make a call to a COM ActiveX object, but even though the call occurs on a separate thread, my UI is still blocking. If i put the thread to sleep in my...
2
by: Javier Bertran | last post by:
Hi all, I have an ActiveX control developed in Visual C++ 6.0 that I want to use in a C# project. I want the ActiveX code to run on a separate thread, but can't seem to get it to work. If for...
5
by: andy.g.ward | last post by:
I keep getting this when trying to create an MFC activex control in a c# windows service - anyone got any ideas what the missing module could be??? Exception thrown :...
5
by: Dan | last post by:
Good Day All, I am having a problem in Visual Studio 2005 Beta 2. I am hoping someone might have an idea as to what is going on. I have an ActiveX User Control written using Visual Basic 6.0....
3
by: fumihiko | last post by:
Hi, I created an activex control (C++), and it uses another COM dll (C++). This COM dll links with a static library that dose some calculation. (both are debug multithreaded dll) I created a...
1
by: Sreejumon [MVP] | last post by:
Hi, If you want to use the activex controls in your asp.net page, you ahev to use the single aprtment thread model. For that please add the "aspcompat=true" attribute the page directive. Let...
6
by: Steve | last post by:
I am working on a emulator and need to have time based events. I've tried to use the timer control and discovered that it runs waaaaaaay slow. I set the tick frequency to 1, then in the tick...
6
by: fantum | last post by:
I have created a small activex dll to do a background task on my web server. I fire it off with a set myjob = server.createobject(myactivex) and it runs. I do not do a set myjob = nothing and so...
6
by: hufaunder | last post by:
I have an ActiveX component that I want to use in a library that I am writing. As a first test I used the ActiveX component in a windows form application. Adding the component created: Ax.dll...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
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,...

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.