|
Luc Pattyn wrote: Operator precedence is the one thing you don't need to remember
Yeah, I know. Hopefully the OP also uses them after this
Luc Pattyn wrote: What makes you think entering parentheses doesn't take any energy?
Oh well, you're right (pizza + coke at least).... There goes the invention.
|
|
|
|
|
"http://personal.denison.edu/~havill/algorithmics/algs/postfix.pdf"
see in second algorithm in above like thats what i wanted...
thanks Luc pattyn
<div class="ForumMod">modified on Tuesday, December 16, 2008 2:14 AM</div>
|
|
|
|
|
If you wondered what OP means, it's Original Poster.
hotthoughtguy wrote: see in second algorithm in above like thats what i wanted
I think the idea Luc gave you will be usable to implement the logic.
|
|
|
|
|
Hi guys,
I am a little new to threading and I need your help please. I am trying to use a background worker thread and can't get it to work:
Here is a little more explanation on my code
I have a button click where I call a function which has a while loop waiting for a status from a piece of hardware.
In my button click event I am calling this.bgwSign.RunWorkerAsync(); and then I wait for the status.
In my bgwSign_DoWork(), I call the while loop which waits for the status from the hardware
In my while loop I have this.bgwSign.ReportProgress(SignatureStatus, timer1.Interval); I don't think this is correct
Please helpppp!!!
Sameer
|
|
|
|
|
Hi,
it is hard to provide detailed help without seeing actual code.
anyway, having a handler (button click or anything else) wait for something that could take hundreds of milliseconds or more, is not a good approach; for one it blocks the entire GUI, and it also defeats the very purpose of using a background worker.
If you need one, here is a good introduction to BGWs[^].
Hope this helps.
|
|
|
|
|
Here is my code. What I am trying to do is to allow the GUI not to be locked while waiting for the status from the signature capture unit.
private void cmdSign_Click(object sender, System.EventArgs e)
{
this.bgwSign.RunWorkerAsync();
if (SigStatus == 1)
{
cmdMgr.Enabled = true;
cmdSign.Enabled = true;
cmdCancel.Enabled = true;
cmdSign.Focus();
//Application.DoEvents();
}
else if (posSignature.GetVAR("btstate") == "btnCANCEL")
{
cmdMgr.Enabled = true;
cmdSign.Enabled = true;
cmdCancel.Enabled = true;
cmdSign.Focus();
SigStatus = 1;
}
else
{
cmdCancel.Enabled = true;
cmdMgr.Enabled = true;
cmdSign.Enabled = true;
cmdSign.Focus();
SigStatus = 1;
}
}
private void bgwSign_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
{
timer1.Interval = 60000;
timer2.Enabled = false;
timer2.Stop();
lblInstruction.Text = "Ask customer to sign the signature pad";
//this.Cursor = Cursors.WaitCursor;
cmdNext.Enabled = false;
cmdSign.Enabled = false;
cmdCancel.Enabled = false;
cmdMgr.Enabled = false;
posSignImage = null;
PboxSignature.Image = null;
try
{
//Application.DoEvents();
timer1.Enabled = true;
timer1.Start();
while (posSignature.GetVAR("btstate") != "btnENTER" || posSignature.GetVAR("btstate") != "btnCANCEL" || SigStatus == 0)
{
if (this.bgwSign.CancellationPending)
{
e.Cancel = true;
return;
}
this.bgwSign.ReportProgress(SigStatus, timer1.Interval);
System.Threading.Thread.Sleep(20);
if (posSignature.GetVAR("btstate") == "btnCANCEL" || posSignature.GetVAR("btstate") == "btnENTER" || SigStatus == 1)
{
timer1.Enabled = false;
timer1.Stop();
break;
}
}
}
catch (Exception ex)
{
SigStatus = 1;
//MessageBox.Show(this, "Error in capturing and saving user signature\n\n\n" + ex.Message);
cmdSign.Enabled = true;
cmdCancel.Enabled = true;
cmdMgr.Enabled = true;
}
finally
{
this.Cursor = Cursors.Default;
}
}
Sameer
|
|
|
|
|
Hi,
that is almost impossible to read, lacking the declarations of lots of variables, and not using
proper formatting (with PRE tags).
The initialization of bgwSign is crucial for it to work properly; I doubt you have it all there,
so I don't think your bgwSign_DoWork even started to run. Did you check?
Also bgwSign_DoWork is not allowed to touch any GUI stuff; I guess you are violating that rule a dozen times with timer1, timer2, cmdNext, etc. You must refrain from touching Forms and Controls in any thread (or BGW) other than the main aka GUI thread. If the GUI needs updating, either use the Control.InvokeRequired/Control.Invoke pattern, or put it in the Progress/Completed handlers of the BGW (those are guaranteed to run on the GUI thread).
I suggest you read up on this.
|
|
|
|
|
Thank you Luc, the link you sent is pretty good and I appreciate your comments.
Sameer
|
|
|
|
|
You're welcome.
|
|
|
|
|
Well, we don't know if you've properly configured the background worker, you didn't show us your ReportProgress delegate, and the the greater sin is that you didn't put your code in a pre block. Pay-f*cking-attention to what *you're* doing so we can help you.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thank you John for your comment, you didn't have to curse to make a point.
Sameer
|
|
|
|
|
Yeah - I really did.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Thank you and God bless you
Sameer
|
|
|
|
|
Do you mean that ReportProgress doesn't work?
If yes, have you set WorkerReportsProgress = true?
I'm sure posting the code will help a lot.
Regards,
Lev
|
|
|
|
|
Hi,
I would like to do something such as in a DLL.
Chart.Header.Add
Chart.Header.Theme.Theme1.Add
Add might just be the function.
I can get to the first level only.
public class Chart
{
public void Header() {}
}
I can call it by Chart.Header.
However, i would not want header to be a method but a property of Chart.
There can be multiple property of chart such as Chart.Datapoint , Chart.Footer and so on. And each of the chart property has it own specific level or methods.
I do not think it is subclass or or inheritance. What is it called and how to to multiple level with multiple "dot".
Thanks in advance.
|
|
|
|
|
In programming parlance its called "Compositing". Using many classes to build up the object model you require.
public class Header
{
...
}
public class Chart
{
private Header header;
public Chart()
{
this.header = new Header();
}
public Header Header
{
get{ return this.header; }
}
}
Chart myChart = new Chart();
myChart.Header.SomeMethod();
you can carry this same idea over to make as many levels of class as you require to model your "thing".
|
|
|
|
|
Thanks J4amieC. That's what i am looking for. "Compositing"
|
|
|
|
|
Not sure what you're asking here, but it is just called the "dot operator". But the dot operator is a mechanism that is used by classes to link their properties, members, and methods together. Here's an example.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DotOperator {
class Program {
static void Main(string[] args) {
Report report = new Report();
report.TheHeader = new Header("This is the News Today");
report.TheArticle = new Article(@"Third suspect indicted in 27-year-old murder
By Bill Hankins
Published December 14, 2008
A third suspect in the 27-year-old murder of Jean Wagnon has been indicted by a Lamar County grand...");
Console.WriteLine(report.GetReport());
Console.WriteLine(report.TheArticle.TheContent.Body);
Console.WriteLine(report.TheHeader.TheContent.Body.Length);
Console.ReadLine();
}
}
public class Report {
public Header TheHeader { get; set; }
public Article TheArticle { get; set; }
public String GetReport() {
return TheHeader.TheContent.Body + Environment.NewLine + TheArticle.TheContent.Body;
}
}
public class Header {
public Header(String header) {
TheContent = new Content(header);
}
public Content TheContent { get; set; }
}
public class Article {
public Article(String main) {
TheContent = new Content(main);
}
public Content TheContent { get; set; }
}
public class Content {
public Content(String theNews) {
Body = theNews;
}
public String Body { get; set; }
}
}
hope that helps.
EDIT: Yea, what J4amieC said.
Scott P.
"Simplicity carried to the extreme becomes elegance."
-Jon Franklin
|
|
|
|
|
I have a feeling you might want to be looking at namespaces?
|
|
|
|
|
Hi,
I am writing a windows application and i want to write the code to know weather .net frame work is there or not and i want to know weather iis is installed or not.
after executing my application i want to run on other system with the help of that exe file.
please send any links or code how to know the framework is installed or not and iis is there or not....
the program should run on other also(where there will be no dot net) system with "Exe file". It should prompt the message that framework is not there
|
|
|
|
|
|
shavil wrote: the program should run on other also(where there will be no dot net) system with "Exe file". It should prompt the message that framework is not there
As far as I know this isn't possible with .NET (in vb6 it is but that's a dead language).
You can however add a setup project wich will create a setup for you (.exe and .msi files)
These will automaticly check for the framework and if its not there offer to download and install it.
|
|
|
|
|
i always resorted to checking the registry to see if IIS is installed, another method is to check the windows service list to see if W3SVC is installed and running
|
|
|
|
|
Dear user i have developed a database software in C#.Net 2005 and sql server 2000. i want this software to run for a specific period of time and only on one computer. so that the client demands for the new version of of the software.
i am waiting for you guidance.
Thank You.
Hamad Salahud-din
By Lucky Hamad
|
|
|
|
|
Do you mean like a trial period? or are you just forcing a user to upgrade after a certain amount of time for no reason? A user should upgrade only because your next release would have more features and specific upgrades that they want, not just because you say $o.
|
|
|
|