|
Hey!
I have some performance problems when I am using a third party dll to read and write to a GSM phone. I first used these commands to read and write in my main thread and noticed that when executing these commands, the application froze for a couple of seconds. The commands worked but the behavior was annoying. I then thought that running these commands in threadd separated from the main thread would solve the problem but it didn't. The application still freezes when using the read and write commands. Does anyone have any idea why? I though threads would solve these kinds of problems.
/Hampus
|
|
|
|
|
Hi,
First of all I assume it is working ?
And I hope the DLL is not doing some GUI stuff of its own.
I guess you only have the DLL, that is not the source, nor a technical description.
You could have a look at the CPU load it creates: open Task Manager, Performance tab
and watch the curve while trying to read/write the GSM. If its close to 100% then
they probably have a busy loop, which is harming your main thread's behavior.
If so, you may try to set a lower priority for that thread;
gsmThread.Priority=ThreadPriority.BelowNormal;
that should solve the GUI part, but may cause the GSM DLL to malfunction...
If CPU load isnt high, they somehow execute (part of) their stuff on the main thread anyhow,
and your thread is pointless.
|
|
|
|
|
Yes, the dll works as it should, it's just slow. It's not doing any GUI stuff.
I have checked the CPU load and it's never close to 100%, rather like 50% but I still tested setting the threadpriority to belownormal but it didn't help.
Does it matter that the object I create, which is defined in the dll and is the object I use to read and write with, is not created in the tread but in the main thread?
/Hampus
|
|
|
|
|
Hampus@foi wrote: rather like 50%
that could mean it is fully loading one of two CPU cores. Do you have either hyperthreading
or a Core Duo CPU ? if so, they have a busy loop, but then the other (half of) CPU might
(or might not) keep your GUI alive. Or they have an internal thread that they (temporarily)
switch to a higher (maybe real-time) priority to make sure they dont miss something.
If so, there is nothing you can do about it (you might notice it with some third-party
tool such as TaskInfo), that might confirm but not solve it.
Hampus@foi wrote: Does it matter that the object I create, which is defined in the dll and is the object I use to read and write with, is not created in the tread but in the main thread?
I dont expect it to matter. Does their documentation say anything about that ?
I guess you will have to contact your DLL vendor...
|
|
|
|
|
Their documentation does not mention anything about their product that could be considered negative, not even in the FAQ
I have contacted them but they have yet not answered...
Thanks anyway!
/Hampus
|
|
|
|
|
You're welcome.
Please post the outcome, if and when.
|
|
|
|
|
In a new atempt to solve this, I tested to create and initialize the write object in the write thread so that it doesn't exist anywhere else but in the thread and this actually seems to have solved the problem. My application no longer freezes when writing data to the GSM phone. I have not tried changing the read process yet but it should probably give the same result.
/Hampus
|
|
|
|
|
Hampus@foi wrote: Does it matter that the object I create, which is defined in the dll and is the object I use to read and write with, is not created in the tread but in the main thread?
You are kidding right? Of course that could matter if they are performing any time consuming task(s) during initialization, which it certainly sound like they are. All you would have to do is put some time elapsed code around the initialization to find out.
|
|
|
|
|
Hi,
I use C# with CsGL to build the 3D models based OpenGL.Now i want to plaint the texture with the class OpenGLTexture2D.But when i use the phrase
"private OpenGLTexture2D tex = new OpenGLTexture2D(@"text.bmp");"
to construct the class,there will report the error of
"TypeInitializationException was unhandled" in the phrase
"Application.Run(new MainForm());" in the file of Program.cs.
How can i deal with this problem? i use the vs2005 and csgl 1.4.1.0
Thanks....
|
|
|
|
|
They are probably not following guidelines and throwing exceptions from a constructor, or in this case a static constructor (as from the exception type).
|
|
|
|
|
Seems like the constructor of OpenGLTexture2D is throwing.
Split the line private OpenGLTexture2D tex = new OpenGLTexture2D(@"text.bmp");
into a member declaration without initializer,
plus an initializer statement somewhere in your code:
tex = new OpenGLTexture2D(@"text.bmp");
and put a try-catch around it, so you catch the exception and learn from all the details
Exception.ToString() holds for you.
|
|
|
|
|
|
The problem has done,tanks....

|
|
|
|
|
Just curiosity , Did anyone have idea of how many methods a single C# class can allow ?
I heard, it is compiler dependent If true, what is the maximum no allowed by the standard compiler ?
Thanks,
Vythees
|
|
|
|
|
vytheeswaran wrote: how many methods a single C# class can allow ?
We can have as we can.
For More Details:
MSDN[^]
Regards,
Satips.
|
|
|
|
|
Where does that article answer the OP's question? Or did you just chuck some keywords in to Google and hit "I'm feeling lucky"?
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Thanks for Info,
But I read in one article that E-Bay once hits the compiler limit in max number of methods in single class.
Thanks,
Vythees
|
|
|
|
|
IIRC ebay is running its servers using c++ and ISAPI, not .net.
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
I agree, I think then there should be the same constraint exist in .NET class also.
Thanks,
Vythees
|
|
|
|
|
Even assuming there is a constraint, you're talking about 2 totally different languages so why should they be the same?
--
You have to explain to them [VB coders] what you mean by "typed". their first response is likely to be something like, "Of course my code is typed. Do you think i magically project it onto the screen with the power of my mind?" --- John Simmons / outlaw programmer
|
|
|
|
|
vytheeswaran wrote: Did anyone have idea of how many methods a single C# class can allow ?
I think that if you ever reached that limit then you might want to seriously reconsider your design.
Upcoming events:
* Glasgow: Mock Objects, SQL Server CLR Integration, Reporting Services, db4o, Dependency Injection with Spring ...
"I wouldn't say boo to a goose. I'm not a coward, I just realise that it would be largely pointless."
Ready to Give up - Your help will be much appreciated.
My website
|
|
|
|
|
Colin Angus Mackay wrote: I think that if you ever reached that limit then you might want to seriously reconsider your design.
or the switch/case limit or the if/elseif limit or the ....
or if none of that makes sense to you try this[^]
|
|
|
|
|
Oh God, thats classic link.
Thanks,
Vythees
|
|
|
|
|
|
Seeing Assembly metatokens takes the following form: 00 000000, where the former is the type, and the latter is the code, I would say the maximum number of methoddef's in an assembly would be limited to 24-bits, iow 16.7 million. Dunno if there is a limitation on a classes though.
|
|
|
|