|
Hi Luc,
I am not sure if I understand you. However, I want to finish running one, and then start the new one. Basically if monitorfunc has not finished I want to pause the call if one minute is passed. Then start the call once it has finished. I hope I am making sense.
Please advice.
Sameer
|
|
|
|
|
OK, so if one run exceeds the allotted time period, you want the current run to terminate normally, and the new run of the function to follow immediately. This is some pseudo-code that would achieve this:
private int activationCounter=0;
void periodicFunction() {
int n=Interlocked.Increment(ref activationCounter);
if (n<=1) {
do {
n=Interlocked.Decrement(ref activationCounter);
} while (n!=0);
}
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
Hi Luc,
Sorry for the delay in my response and thank you for your responses. I couldn't implement your code, I am not sure if I am doing something wrong. I have put in another posting requesting guidance on building a service with a thread that looks at a folder for files and processes the file. Upon completion of the processing, it starts over again.
Help if you can please on that.
Sameer
|
|
|
|
|
Saamir wrote: I couldn't implement your code
that is extremely vague and uninformative, no one can help you based on this.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
bool stop = false;
...
Thread t = new Thread(new ThreadStart(run)){IsBackground = true}.Start();
...
private void run(){
while(!stop){
Thread.Sleep(60000);
MonitorFunc();
}
}
|
|
|
|
|
thank you for your response. I am using timercallback currently, sorry for my ignorance in threading but I am not sure how to modify all my current code to implement your method.
Sameer
|
|
|
|
|
That is not really what the OP wanted, since it will pause for an entire minute in between two executions, whereas the OP wanted it to run every minute.
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
i'm trying to develop a data storing component, for it i'm in doubt about using datasets , as i heard datasets are not efficient in memory usage over Lists , is it true
|
|
|
|
|
Do what most people would do.
Develop test routines utilizing each data structure and run them in a loop maybe 1000 times (or more) and time them to find out which works best for your data.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Hi,
i want to use web cam to capture pictures. to use webcam i have to user avicap32.dll. so how can i add this to reference. i tried by add reference, but couldn't any one please just tell me how can i use avicap32.dll ....
thanks
A S E L A
|
|
|
|
|
I believe you need to use pinvoke with that dll.
This article[^] uses it, you may find it of use.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn) Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia) Why are you using VB6? Do you hate yourself? (Christian Graus)
|
|
|
|
|
If the camera supports Windows Image Acquisition (WIA), it's easier to use that. (See here[^])
If it doesn't, then yes acicap32 is an option. (There's a sample here[^])
I believe it would also be possible to do it with direct show, but I think it's probably a bit harder. (see here[^])
Finally there are 3rd party libraries out there that can do things like this. One example is OpenCV[^], and the OpenCVDotNet[^] wrapper.
Simon
|
|
|
|
|
Hi, I want to know all the actions that are performed on internet explorer, how can I do these all things?
I want to do these all on client side?
How can I know the information regarding somethings which have been done on web page, For example, things like:
1. How to convert the web page text on fly as there is no onload event
2. How to catch the keyboard actions like keyup, keydown, keypress when something
typed on web page.
3. How to know the information that if something is given to printer, i.e., text that is going to print, from an IE window.
Like these things, I want to get all the things when we perform some action on IE window through a plug-in.
How can I get these all things in c#?
Thank you...
|
|
|
|
|
Hi
I'm having a problem solving this problem.
I have an XML file describing how the different types (double, float, int and so on) should be interprettet, or how many bits the size of them should be. My application reads the XML and then have to cast for example a double to a float or an int to a short, based on the configuration. Afterward, the new casted or converted value has to converted to a byte array of the size of the type defined in the XML file.
I will just give an example to clarify.
1. Double value received.
2. Convert double value based on the conversion size in XML, double is cast / converted to float.
3. Create byte array from casted / converted value.
I can convert the value without problems using Convert.ChangeType(doubleValue,Type.GetType("System.Single")), but this give an object that I do not know how to make to a byte array of the correct size (32 bits).
Can anyone help me with solving the problem with converting / casting a double to a specific type defined in a XML file and converting this to a byte array ?
What I'm interrested in is the byte array being the size defined in the XML with signed values.
Thanks alot
Dennis
|
|
|
|
|
Dennis Lerche wrote: converting this to a byte array
Maybe this[^] will work.
|
|
|
|
|
Yes it works ok, unless you have an object and not a double, float etc.
What I have is an object after performing Convert.ChangeType(doubleValue,Type.GetType("System.Single")), so how do I make this to a byte[] ?
|
|
|
|
|
The solution I have found is the following:
static byte[] ValueToByteArray(object obj)
{
int len = Marshal.SizeOf(obj);
byte[] arr = new byte[len];
IntPtr ptr = Marshal.AllocHGlobal(len);
Marshal.StructureToPtr(obj, ptr, true);
Marshal.Copy(ptr, arr, 0, len);
Marshal.FreeHGlobal(ptr);
return arr;
}
This takes any of the int, double etc. types as an object and converts it to a byte[].
|
|
|
|
|
Hi
I know it's a simple question but I couldn't find it with searching on google.
string a = "asdasd;asdasdasder;asdgfg;ad;;asdasd";
How can I count the number of ;'s in this string?
Thanks.
|
|
|
|
|
|
SimpleData wrote: I know it's a simple
Yes.
string a = "asdasd;asdasdasder;asdgfg;ad;;asdasd";<br />
<br />
int charCount = 0;<br />
<br />
for (int i = 0; i <= a.Length - 1; i++)<br />
{<br />
if (a[i].ToString() == ";")<br />
{<br />
charCount += 1;<br />
}<br />
}
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Blue_Boy wrote: a[i].ToString() == ";"
is a terrible waste
a[i] == ';'
Luc Pattyn [Forum Guidelines] [My Articles]
The quality and detail of your question reflects on the effectiveness of the help you are likely to get.
Show formatted code inside PRE tags, and give clear symptoms when describing a problem.
|
|
|
|
|
int LiCount = 0;
foreach (char Lchar in a.ToCharArray())
{
if (Lchar == ';')
LiCount++;
}
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi
Thanks you all your answers. I don't know why I couldn't think of this solution. Sometimes I can't think, and this is one of those times I guess.
|
|
|
|
|
int iCount = ("asdasd;asdasdasder;asdgfg;ad;;asdasd".Split(';')).Count<string>() - 1;
Well that gets it down to one line. What's next, obfuscation?
The true man wants two things: danger and play. For that reason he wants woman, as the most dangerous plaything.
|
|
|
|
|
Nice but,instead
Count() (which is not method) you have to use
Length int property
int iCount = ("asdasd;asdasdasder;asdgfg;ad;;asdasd".Split(';')).Length- 1;
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|