i have a problem with timer because it is not panctual :S i have set interval to 10ms. that is the code in timer_tick
----------------------------------------------------------------------------------------------
private: System::Void CelotenCas_Tick(System::Object^ sender, System::EventArgs^ e) { this->PreverjanjeZacetka->Stop(); this->CMeritve->Milisekunde=this->CMeritve->Milisekunde+10; this->VCasi->SkupneMilisekunde+=10; //skupne milisekunde if (this->CMeritve->Milisekunde==1000) { this->CMeritve->Sekunde++; //ce mamo dost sekund // this->VCasi->SkupneSekunde++; //celoten cas v sekundah this->CMeritve->Milisekunde=0; //dodamo minuta } //pa damo sekunde na 0, velja za msec in sec if (this->CMeritve->Sekunde==60) { this->CMeritve->Minute++; //PRETVARJANJE IZ SEKUND V MINUTE PA ... this->CMeritve->Sekunde=0; } this->VCasi->VmesneVrednistiIN=this->LPT->Lpt_Read(888+1); if (!this->VmesniZacetek) { if (this->VCasi->VmesneVrednistiIN==254) { this->VmesniZacetek=true; this->VmesniCas->Start(); this->LVmesniCas1->Text=this->CMeritve->Minute.ToString()+":"+this->CMeritve->Sekunde.ToString()+":"+this->CMeritve->Milisekunde.ToString(); }} // this->CMeritve->KonecMeritve=this->LPT->Lpt_Read(LPTOUT+1); //Vm,ESNI CAS this->VCasi->VmesniCas2=this->LPT->Lpt_Read(888+1); if(!this->VmesniKonec) { if (this->VCasi->VmesniCas2==110) { this->VmesniKonec=true; this->VmesniCas->Stop(); this->VCasi->seEneMilisekunde=System::Convert::ToDouble(this->VCasi->VmesneMilisekunde); this->VCasi->seEneMilisekunde*=0.001; this->VCasi->PomozneSekunde+=this->VCasi->seEneMilisekunde; this->neki=this->DolzonaRavnine->Text->ToString(); this->VCasi->DovzinaRavninePOm=System::Convert::ToInt32(neki); this->VCasi->DovzinaRavnineVM=this->VCasi->DovzinaRavninePOm*0.001; this->VCasi->MaxSpeed=this->VCasi->DovzinaRavnineVM/this->VCasi->PomozneSekunde; this->VCasi->MaxSpeed=this->ShraniVFile->Zaokrozi(this->VCasi->MaxSpeed,3); // this->VCasi->MaxSpeed/=0.001; this->LCelotenSpeed->Text=this->VCasi->MaxSpeed.ToString(); this->LVmesniCas2->Text=this->CMeritve->Minute.ToString()+":"+this->CMeritve->Sekunde.ToString()+":"+this->CMeritve->Milisekunde.ToString(); } } this->VCasi->koncniCas=this->LPT->Lpt_Read(888+1); //merjenje SPEEEDA POVPRECNEGA if (this->VCasi->koncniCas==94) { this->CelotenCas->Stop(); //this->PreverjanjeZacetka->Start(); this->VCasi->SkupneMilisekunde*=0.001; //da dobimo sekunde this->seneki=this->DolzinaLabirinta->Text->ToString(); this->VCasi->CelotnaDovzina=System::Convert::ToDouble(this->seneki); //dovzina labirinta v metrih this->VCasi->PovprecenSpeed=this->VCasi->CelotnaDovzina/this->VCasi->SkupneMilisekunde; //this->VCasi->PovprecenSpeed*=0.1; this->VCasi->PovprecenSpeed=this->ShraniVFile->Zaokrozi(this->VCasi->PovprecenSpeed,3); this->label11->Text=this->VCasi->PovprecenSpeed.ToString(); } //zadevo e izpi emo na zaslon this->label1->Text=this->CMeritve->Minute.ToString()+":"+this->CMeritve->Sekunde.ToString()+":"+this->CMeritve->Milisekunde.ToString(); } |
--------------------------------------------------------------------------------------------
i am counting ms and converting them to secounds and minutes and then writeing them to label but timer is not panctual :S i am not getting right time :S
any idea what should be wrong :S

timer is not panctual
dwhsix
For higher resolution you should use the multi-media timers. See the following link for details:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/multimed/htm/_win32_multimedia_timers.asp
Ronald Laeremans
Visual C++ team
FavorFlave
PerGeert
Giant_Panda
Stopwatch watch = new Stopwatch();The number of ticks per millisecond on my 3.0GHz Pentium 4 machine is 10,000.
Brian
Joppe Pelarn
LP
Rayman2