|
I didn't quite follow all that, but I still see no reason to downgrade the instances.
|
|
|
|
|
Think about it. When you derive a class from baseClass, you are adding information to baseClass. When you try to convert your derived class to a baseClass, you would have to throw information away. You could not recover the information by re-casting your item to a derivedClass, because otherwise your program would have to behave very differently with the following :
derivedClass d = new derivedClass();
baseClass b = d as baseClass;
derivedClass d2 = (derivedClass) b; and
baseClass b = new baseClass();
derivedClass d2 = (derivedClass) b;
If the definitions were in (say) different methods to the casts, it could get very difficult to work out what is going on.
Since wherever you can use a baseClass, you can use any derived class, C# is not keen on throwing away information, which could not be recovered by a re-cast back to the derived class.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
|
Im trying to track how long between certain things happening in my app. When the first event happens im adding the time to an array like this: myArrList.Add(DateTime.Now);
Then when the next event happens im retreiving it from the array and doing this:
TimeSpan diff = DateTime.Now - (DateTime)myArrList[x];
But for some reason it always gets like 0.02 seconds. Which makes me think that its doing the current time minus the current time(and the 0.02 is the time it takes between finding the first time and the second).
So how do i do this properly?
Am I adding a reference to DateTime.Now into the array instead of just the value?
Thanks
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
No, when you get DateTime.Now you get just that - the time now, which will not change thereafter. So if you write
DateTime dt = DateTime.Now;
at noon, dt will still say noon at 13:00.
How long is the actual interval between the two events? Are we talking microseconds? Seconds? Minutes? How frequently is your event happening? Once? Or every (say) 20ms?
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Well it is usually around a second or less
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
You might want to take a look at the Stopwatch[^] class
only two letters away from being an asset
|
|
|
|
|
Looks good! TY
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
roguemat wrote: Am I adding a reference to DateTime.Now
No. DateTime is a value time (a struct), no references involved.
roguemat wrote: it always gets like 0.02 seconds
DateTime.Now as well as the system clock get updated only a few times a second (typ. 60 Hz); see my timers article. If you need better accuracy, use a Stopwatch.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Will check it out thanks!
Strive to be humble enough to take advice, and confident enough to do something about it.
|
|
|
|
|
Hi , I am developing software to read the tiff images. i need to read the text written in tiff images programmatically in c#. I have lakhs of tiff image to process it for cleaning and reading. also i want to develop thumbnails programmatically of those tiff scanned images.
Regards,
Lalit Singh
Programmer Analyst
Hitech Outsourcing Services
|
|
|
|
|
How about searching it in codeproject, search for "OCR". You find lots of article of it.
|
|
|
|
|
Salut,
Lorsque je click sur le multicolumncombo, je veux avoir une table de 2 colonnes qui ont pour noms codeArticle et
description et cette table est remplie à partir de la base de données.En selectionnant une ligne,la description
sera affichée.Est-ce qu'il y a quelqu'un qui peut m'aider à faire ceci?
|
|
|
|
|
Vous obtiendrez une réponse plus rapide si vous utilisez l'anglais.
Thank heavens for google translate.
CCC solved so far: 2 (including a Hard One!)
|
|
|
|
|
Here's a 5 just for making the effort to translate it.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
Help humanity, join the CodeProject grid computing team here
|
|
|
|
|
Vous pourriez avoir plus de chance demandant aux auteurs de ces contrôles dans leur forum de support comme la plupart des gens ici n'ont pas travaillé avec ces contrôles.
|
|
|
|
|
Parlez-vous de contrôle d'élaborer sur mesure?
Il n'ya rien comme combo multi-colonnes en. NET.
|
|
|
|
|
MultiColumnCombo est un contrôle de la bibliothèque janus.
|
|
|
|
|
Hi, I'm currently working on a cyber cafe program and I need to use 2 timers for each table's calculations and there are 25 tables(pc's).The question is, does using many timers(with 100ms intervals) have any impact on the performance?
And referring to 2 timers, there are two different calculations(time and price)which occur at different intervals.Is it possible to handle them in one timer?
last question(sorry ) Is it good to make all controls and variables public to access from other forms?
Your help would be appreciated,thanks
|
|
|
|
|
I can answer the last, and probably the second of those.
teknolog123 wrote: two different calculations(time and price)which occur at different intervals.Is it possible to handle them in one timer?
Only if the two intervals happen at multiples of each other. If one is due at 100ms and the other at 123ms intervals, then you cannot handle them both easily from the same timer. If one is due ate 100ms and the other at 500ms intervals, then yes, just count 5 instances of the timer event.
teknolog123 wrote: Is it good to make all controls and variables public to access from other forms?
No. This is very bad practice as it locks the design of your form, and you cannot change it without making changes in an unknown number of other forms. Use public properties instead, as the underlying form elements are hidden and can be changed without affecting external code.
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
I already use public properties for variables but have no idea what would be the best way to access another form's controls without compromising performance.Any idea?
thanks
|
|
|
|
|
It is really not a good idea to directly access the controls on another form: If you later change from say 5 text boxes to a single listview, then how many other forms are dependant on that code? You have find and modify all of those. Instead, use public methods and properties - I wouldn't worry to much about any performance hit, it is cheaper to upgrade the PC than to waste programmer time fixing problems you create with bad design in the first place!
No trees were harmed in the sending of this message; however, a significant number of electrons were slightly inconvenienced.
This message is made of fully recyclable Zeros and Ones
|
|
|
|
|
Hi,
I see no problem in running 50 timers at once. (I tested with Windows.Forms.Timers)
If all intervals are 100 msec, then:
1) your average handler should finish in 2 milliseconds, otherwise your app will accumulate a delay;
2) I see no reason to have separate timers, as they will all tick at the same time;
Anyway:
1) I would avoid running that many timers; it tells me something is wrong in your design; I would start by using one timer for everything, and add many handlers to it.
2) It seems to me you are polling something, rather than relying on events. What is it that you are testing in the tick handler?
3) why would you need a 100 msec interval? are you charging customers for connection time up to a fraction of a second???
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|
|
Luc Pattyn wrote: 1) I would avoid running that many timers; it tells me something is wrong in your design; I would start by using one timer for everything, and add many handlers to it.
Could you please give me an example of adding handler to a timer?
Luc Pattyn wrote: 2) It seems to me you are polling something, rather than relying on events. What is it that you are testing in the tick handler?
Basicly the timer will increase the price and time every x minutes, that's it(all pc's will increase at the same interval even if some pc's are off and some are on)
Luc Pattyn wrote: 3) why would you need a 100 msec interval? are you charging customers for connection time up to a fraction of a second???
No I am not that miser. There are times that I give customers extra plus or minus minutes for delays/breaks. And of course this action requires changes on the time and price.When I use intervals like x minutes, It doesn't update the form right away
|
|
|
|
|
Hi,
myTimer.Tick+=new EventHandler(t_Tick);
myTimer.Tick+=myFirstHandler;
myTimer.Tick+=mySecondHandler;
...
myTimer.Tick+=myTenthHandler;
teknolog123 wrote: the timer will increase the price and time every x minutes,
and that is why it ticks at 100 msec intervals??
teknolog123 wrote: When I use intervals like x minutes, It doesn't update the form right away
So you did something wrong in the implementation. That's no reason to alter your design.
I'll stick with a single timer, and have it run every 1 or 10 seconds or so. And I'd make sure all the forms show up-to-date information all the time.
Luc Pattyn
Local announcement (Antwerp region): Lange Wapper? Neen!
|
|
|
|