|
Hi,
it seems like you have a thread with a priority above normal (hence above the UI
thread) and with a "busy loop" (while !quitthread GetImage). It is not
apparent from the code shown that this loop ever relinquishes the CPU;
if it does not, there is a design error (not a language issue) and I would
suggest you add a Thread.Sleep(100) somewhere, possibly in the else of your
newimg test.
Hope this helps.
|
|
|
|
|
hi luc,
yes correct, but also if i'm not using the priority above normal, it's showing the busy gui. and on my side it's not safe to use a sleep in this infinite loop, because i'm waiting for trigger signals from the device and using the sleep could miss some signals.
i mean, i tried exactly the same in c++ without any sleep, with and without higher priority and it's working nicely. so what's the difference between c++'s and .net's threading?
criss
|
|
|
|
|
Hi Criss,
I know of no major difference between the threading model available in .NET and
the one in C++; they both are built on top of the Windows kernel capabilities.
The scheduler's behavior varies from one Windows version to the next;
the theoretical "highest ready process gets all, highest ready thread gets all"
is not followed, Microsoft has decided long time ago to reserve some CPU cycles
to the lower-priority ready processes/threads (but not enough to keep your
UI really responsive !). Nevertheless it is a bad idea to have a busy thread,
i.e. a thread that loops without explicitly relinquishing the CPU (as with a
Thread.Sleep or some semaphore wait or something).
So if you claim you have two implementations (C# and C++) that, running on the
same machine, behave quite differently, I am puzzled, that is the only
explanation I can offer is you have a bug somewhere.
I am worried about your "not missing some signals": you cannot prevent a Windows PC
from focusing on something else (networking, floppy/CD access, whatever).
To be safe, you should have full handshake (in my opinion that means the
"4 arrow" model) for all events you want to be sure to see. The only real
alternative is to have a real-time thread, which definitely is not supposed
to execute infinite loops...
BTW: what is the hardware interface and the comm protocol you are using ?
and what is the OS, and the .NET version ?
|
|
|
|
|
Krzysztof Gorgolewski wrote: and on my side it's not safe to use a sleep in this infinite loop, because i'm waiting for trigger signals from the device and using the sleep could miss some signals.
If the code would be so time critical, then it would not be possible to maintain a GUI at all while it's running, as the thread does not get any CPU cycles while the GUI is being updated.
Try to put a Thread.Sleep(0) in the loop to allow any CPU time at all to go to the GUI thread.
---
single minded; short sighted; long gone;
|
|
|
|
|
the blocking method is the "taking image" (GetImage) method. it's waiting till a signal is triggering the device DIRECTLY. for the device i can setup a "timeout" which i have to set to some seconds. so my problem is not the entire infinite busy loop, it's the GetImage method, which is not returning until it gets a trigger or a timeout occurs. because of this i put it in a seperate thread, to get the gui not blocked.
i'm also confused
btw: i'm using: winxp + .net 2 + usb connected camera device
criss
-- modified at 5:41 Monday 16th April, 2007
|
|
|
|
|
Then it depends on how the GetImage is implemented. If it doesn't allow other threads to run while it's waiting, it won't make any difference that it runs in a different thread than the GUI.
If I understand it correctly, the process scheduler can fully handle the time sharing between applications, but it depends on all the threads in an application to cooperate for the time sharing to work between the threads within the application.
---
single minded; short sighted; long gone;
|
|
|
|
|
hm... i see, so that means, there is a difference between the implementation for c++ and c#.net (which is an activex control) for this method/class. i think, i should directly contact the support for the device because it's not more looking as a .net problem, more like the implementation...
thanks guffa
criss
|
|
|
|
|
Hello,
I think you also have to invoke the display method, as you are getting the image instance from an other thread!
All the best,
Martin
|
|
|
|
|
hi martin,
worth to try, but i don't think so... the image is displayed correctly. just the "taking image" method causes the problem, it's waiting the whole "timeout" time for a signal (trigger) and if any occurs, then the image is coming. because of the waiting (and blocking the gui) i'm forced to use a thread.
criss
|
|
|
|
|
Hello,
Yes I know that this is not going to solfe your problem.
I just think if your thread is finished (and you display this image which you are getting from the thread) you will see the original image before you started the thread.
For your problem:
Mabe a Application.DoEvents() helps you.
All the best,
Martin
|
|
|
|
|
thanks to all i bothered with my problem. i could solve it by contacting the devices support... it really just depends on my GetImage method.
anyway. greetings
criss
|
|
|
|
|
Initially XML file is like this
<?xml version="1.0" ?>
<lasers>
<laser LaserName="Laser1" ModelName="Nufern v1.0" SerialNo="1" ManufacturerName="Nufern v1.0" Maximumpower="200w" >
<properties">
<image>CW-Waveform.jpg</image>
<WaveTypes>
<WaveType Name="CW Ramp" url="ramp.html" isavailable="true" />
<WaveType Name="CW Analog" url="analog.html" isavailable="true" />
</WaveTypes>
<tabular>
<property id="228" name="BRM" currval="0" prgbar="true" selected="true" min="0" max="100" pwd="true" units="C" gauge="false" thresholdval="10" />
<property id="200" name="Output power" currval="0" prgbar="true" selected="true" min="0" max="100" pwd="false" units="C" gauge="true" thresholdval="10" />
</tabular>
</properties>
</laser>
</lasers>
then
>>>>>>>>>>>>>>>>>>>>namespace is EncryptDecrypt
XmlDocument xmldoc = new XmlDocument();
xmldoc.Load(Application.StartupPath + @"\laserProp.xml");
XmlNamespaceManager mgr = new XmlNamespaceManager(xmldoc.NameTable);
mgr.AddNamespace(string.Empty, "urn:MyNamespace");
XmlNodeList xmlnodelist;
XmlElement ele = xmldoc.DocumentElement;
xmlnodelist= ele.SelectNodes("//lasers//laser//properties//tabular//property",mgr);
Is working fine but, to validate xml with xsd i made changes to the xml as
<?xml version="1.0" ?>
<lasers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns="urn:MyNamespace" xsi:schemaLocation="urn:MyNamespace laserProp.xsd">
<laser LaserName="Laser1" ModelName="Nufern v1.0" SerialNo="1" ManufacturerName="Nufern v1.0" Maximumpower="200w" xmlns:ns="urn:MyNamespace">
<properties xmlns:ns="urn:MyNamespace">
<image>CW-Waveform.jpg</image>
<WaveTypes>
<WaveType Name="CW Ramp" url="ramp.html" isavailable="true" />
<WaveType Name="CW Analog" url="analog.html" isavailable="true" />
</WaveTypes>
<tabular>
<property id="228" name="BRM" currval="0" prgbar="true" selected="true" min="0" max="100" pwd="true" units="C" gauge="false" thresholdval="10"/>
<property id="200" name="Output power" currval="0" prgbar="true" selected="true" min="0" max="100" pwd="false" units="C" gauge="true" thresholdval="10"/>
</tabular>
</properties>
</laser>
</lasers>
Now the same xpath is working fine but getting validation errors
my xml scheema file is(xsd file)
<?xml version="1.0" encoding="utf-8"?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:MyNamespace">
<xs:element name="lasers">
<xs:complexType>
<xs:sequence>
<xs:element name="laser">
<xs:complexType>
<xs:sequence>
<xs:element name="properties">
<xs:complexType>
<xs:sequence>
<xs:element name="image" type="xs:string" />
<xs:element name="WaveTypes">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="WaveType">
<xs:complexType>
<xs:attribute name="Name" type="xs:string" use="required" />
<xs:attribute name="url" type="xs:string" use="required" />
<xs:attribute name="isavailable" type="xs:boolean" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="tabular">
<xs:complexType>
<xs:sequence>
<xs:element maxOccurs="unbounded" name="property">
<xs:complexType>
<xs:attribute name="id" type="xs:integer" use="required" />
<xs:attribute name="name" type="xs:string" use="required" />
<xs:attribute name="currval" type="xs:integer" use="required" />
<xs:attribute name="prgbar" type="xs:boolean" use="required" />
<xs:attribute name="selected" type="xs:boolean" use="required" />
<xs:attribute name="min" type="xs:integer" use="required" />
<xs:attribute name="max" type="xs:integer" use="required" />
<xs:attribute name="pwd" type="xs:boolean" use="required" />
<xs:attribute name="units" type="xs:string" use="required" />
<xs:attribute name="gauge" type="xs:boolean" use="required" />
<xs:attribute name="thresholdval" type="xs:integer" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="LaserName" type="xs:string" use="required" />
<xs:attribute name="ModelName" type="xs:string" use="required" />
<xs:attribute name="SerialNo" type="xs:integer" use="required" />
<xs:attribute name="ManufacturerName" type="xs:string" use="required" />
<xs:attribute name="Maximumpower" type="xs:string" use="required" />
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
please help me on this
thanks in advance
praveenkumar palla
|
|
|
|
|
Your XPath is still looking for elements from the empty namespace, since you cannot associate a namespace with the empty string as prefix. Unfortunately XPath has no mechanism like declaring a default namespace. You have to associate your namespace with an explicit prefix and use this to qualify all element names in your XPath expression.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
No xpath is working fine but getting validation errors like
couldn't fine the lasers element and etc
thanks
praveenkumar palla
praveenkumar palla
|
|
|
|
|
Ok I see, but the problem is quite similar. You get the validation errprs since your XML document isn't valid according to the schema. The schema expects the elements to be in the "urn:myNamespace" namespace but all of the elements in your document are in the empty namespace (that's why the XPath is working). Either you prefix the elements in your document with the prefix to which you have associated the namespace (using the "xmlns:ns="urn:myNamespace") or much easier you declare your namespace to be the default namespace ("xmlns="urn:myNamespace" on the root element).
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I tried this but xpath is not working
thanks
praveenkumar palla
praveenkumar palla
|
|
|
|
|
praveenkumar palla wrote: I tried this but xpath is not working
I know and I told you why in my first posting. Maybe you do a bit research on XML namespaces, since you're obviously not getting the concept. You could start with the W3C Recommendation Namespaces in XML 1.0 (Second Edition)[^], which in contrast to other W3C documents is quite comprehensible.
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
I've answered this twice, and you've posted it six times. Did you ever consider taking the advice you'v been given ?
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
You need to tell politely, As new users in intention to get immediate reply might do it !! So as a senior member of this site you need to give proper advice
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
Proper advice ? I've told him exactly what is wrong, twice. I've told him several times to stop asking again and again, and that he should try to do what has been advised to him, or at least ask a question that indicates he tried what he's been told ( at least three times, two from me ), to do.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Actually, Christian is perfectly entitled to his frustration and anger. If you take the trouble to look through the posting history of the OP, you will see that he has asked the same question again and again. He has been given advice on what he needs to do many times, and Christian is one of the people who has told him what he needs to do. It is insulting to the people who have tried to help him for the OP to repost the question.
If you follow the threads, you will see that he is given advice on what he needs to do, but the poster does not seem to want to actually do the work. He wants somebody else to actually do his thinking for him. This is not the intention of this site. It is about people freely volunteering their time to help others, and help very rarely involves actually doing the thinking for somebody else. If somebody presents you with a complete solution to a problem then what do you learn? Only that somebody else knows how to troubleshoot/problem solve, and that is not helping you in any way.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Ok, No problem at all... I agree with what you say as far as learning is concerned !!!
Regards,
Jaiprakash M Bankolli
jaiprakash.bankolli@gmail.com
http://jaiprakash.blog.com/
|
|
|
|
|
Mental no. Ignorant Yes.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Yeah, so it would seem. I mean, does he not want to solve the problem ? One has to assume he's achieved nothing at work for several days, while he waits for the laws of computing to change, so that a different answer suddenly solves his issues.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: One has to assume he's achieved nothing at work for several days, while he waits for the laws of computing to change, so that a different answer suddenly solves his issues.
It's this attitude that really bugs me. With several of the consultancies churning out "developers", this is the end result. Give them a problem to solve, or a chance to learn and they flounder hopelessly out of their depth.
Deja View - the feeling that you've seen this post before.
|
|
|
|