|
leppie wrote: Disregard the other answers!
Perhaps you should try to understand the other answers before making such a statement.
leppie wrote: Your 'break' needs to be after the disabling of the timer
Although that is true, it is not the cause of the problem.
Moving the break will not make the timer work. As the tick event is never triggered, the code that sets the flag is never executed, so the code you are talking about is never even reached. Changing code that is never reached will not change how the program works.
---
single minded; short sighted; long gone;
|
|
|
|
|
Hello,
You could use the System.Threading or System.Timers Timer instead of the Forms.Timer.
This Timers are executed in an new Thread and will not be blocked by the GUI Thread.
But make shure that you clearify your concept as Guffa suggested before you are using the timer.
All the best,
Martin
|
|
|
|
|
Thank you very much for your suggestion. I just used doevents() for now and it is working. I will research more into your suggestion. Thanks again.
sasa
|
|
|
|
|
Hello,
Maybe I was not clear before.
I will never suggest to stay at your concept, and build a workaround with a Threading Timer. I also do not like the DoEvents solution, which will have a lot of different side effects in your application.
All the best,
Martin
|
|
|
|
|
Hi Martin,
I do not agree. It is technically correct another kind of timer would
be able to intervene, but a while-forever loop in the main thread is
unacceptable; it prevents normal GUI interaction such as moving the form.
Once things get handled in a decent way, any timer can do what is needed,
so the Forms.Timer can stay.
Regards,
|
|
|
|
|
Hello Luc,
Luc Pattyn wrote: I do not agree
I don't think that you have to disagree.
Luc Pattyn wrote: but a while-forever loop in the main thread is
unacceptable
I completely agree with you!
That's why I suggested or better pointed out, that he should better change his concept, like Guffe suggested.
Maybe it was not understandable enough.
Presenting the posibility of the other Timers was just meant as an additional info!
All the best,
Martin
-- modified at 15:45 Friday 29th June, 2007
|
|
|
|
|
Hi Martin,
I am sure we agree. But we may use different styles:
I try not to present information that increases the chance the heart of the problem
is not dealth with.
As we all know, apps must be built with a good architecture, and not based on some
shaky code that has been tweaked until it seems to work.
Now if we dont try to get basic things corrected early on, a poster will come
again and again, every time he wants to add or correct a small thing, and it
becomes more and more difficult to set things right.
Greetings,
|
|
|
|
|
I am trying to open a C# app and sense if there are any open workbooks and then return thier names.
I can open a new one and sense it, but I want to sense any that are already open.
Thanks in advance for any assistance.
Jeff Beagle
jeffbeagle@hughes.net
|
|
|
|
|
Does anyone know how to implement ActiveX Persistence in C#? From an article on Code Project I discovered how to create an ActiveX object in C# but it does not implement any persistent interface.
Thank you.
Michael
|
|
|
|
|
How to count to optional item occurence in array? I looked at it all array class methods, but I did not find one like this.
I say thank you for the help!
|
|
|
|
|
What do you mean ?
Array.Length ?
|
|
|
|
|
No, example:
using System;
class Alkalmazas {
public static void Main() {
int[] array = new int[10];
array[0] = 1;
array[1] = 1;
array[2] = 1;
array[3] = 2;
array[4] = 1;
array[5] = 2;
array[6] = 1;
array[7] = 1;
array[8] = 2;
array[9] = 3;
Console.WriteLine(array.?); // output: '1' occurrence is 6
Console.WriteLine(array.?); // output: '2' occurrence is 3
Console.WriteLine(array.?); // output: '3' occurrence is 1
}
}
|
|
|
|
|
In that case, use a Dictionary or Hashtable
|
|
|
|
|
Array items are not optional. An arrays has a fixed size, and every item in the array has a value.
If you mean an array of references where you have null values, there is no built-in method for the special case of counting non-null items in arrays of references.
---
single minded; short sighted; long gone;
|
|
|
|
|
Look at Array.FindAll(), you can use the resulting array's length, eg:
int[] result = Array.FindAll(inputArr, delegate(int i) { return i > 5; });
Console.WriteLine(result.Length);
|
|
|
|
|
Yes, I gave a thought to this. Thank you very much, indeed!
|
|
|
|
|
Apart from leppie's solution you might want to have a look at the free PowerCollections library.
PowerCollections[^]
Then you can do:
int[] array = new int[10];
array[0] = 1;
array[1] = 1;
array[2] = 1;
array[3] = 2;
array[4] = 1;
array[5] = 2;
array[6] = 1;
array[7] = 1;
array[8] = 2;
array[9] = 3;
int count1 = Algorithms.CountWhere(array, delegate(int i) { return i == 1; });
Console.WriteLine("Count = {0}", count1);
int count2 = Algorithms.CountWhere(array, delegate(int i) { return i == 2; });
Console.WriteLine("Count = {0}", count2);
int count3 = Algorithms.CountWhere(array, delegate(int i) { return i == 3; });
Console.WriteLine("Count = {0}", count3);
PowerCollections consists of additional data structures and algorithms, somewhat similar to C++'s STL. It's very easy to use. Just reference the DLL and add a using statement. It was written by a former member of the C# team and went though quite a lot of beta testing. There is another possibly more advanced library called C5, which I've never used.
Kevin
|
|
|
|
|
Hi i am using ndoc tool to document my application. In my application i have 10-12 classes and one class is a testing class where i have created small methods just to test the different functionalities of application.
Well to create document with ndoc i needed .dll file for which i created .dll via
project properties-> application-> ouput type-> class library..
Now when i create document via ndoc it only creates my testing class document. Icluding all the testing methods i wrote. But what about the rest of the classes.
Have i created .dll correctly.
In xml file it gives info about rest of the classes. but why not via ndoc...yeh through main method i am calling only that testing class and its methods..
Any one here familiar with NDOC...?
Thanks
|
|
|
|
|
NDoc config by default leaves out privent members. Are your classes non-public? If that's not the issue, then I don't know.
|
|
|
|
|
yeh all the classes member variables are private..so this is the reason its not including all the classes..... well any way out so that it includes everything..
thanks
|
|
|
|
|
Look at the various settings in the NDoc GUI. You should be able to get everything that you need. I assume you are using VS 2003/.NET1.1 because .NET 2.0 is not officially supported in NDoc.
Kevin
|
|
|
|
|
yeh i changed few settings from NDoc GUI and it worked...And yeh i am using VS 2005 and it is supporting. Yeh officially this project is closed and no more update would be available for this.
Thanks
|
|
|
|
|
If you run into problems with NDoc then MS's Sandcastle[^] is the way to go. I haven't tried it myself yet though.
Kevin
|
|
|
|
|
I believe NDoc has an option to include privates though. I wouldn't change code just so that they show.
|
|
|
|
|
Hi,
I have two datatables the first consists of 4 columns Name, Test1, Test2, Test3 and numerous rows
and the second consists of 4 columns
Result, Test1, Test2, Test3
Min,?, ?, ?
Max,?, ?, ?
Average,?, ?, ?
So basically I need to fill the second table with the Min, Max and Average of the tests in the first table im not quite sure what the best way to go about this is so any help of advice would be appreciated
Thanks in advance
Tim
|
|
|
|