Jump to content

SUBIECTE NOI
« 1 / 5 »
RSS
Info Coronavirus/Vaccinare vs Fake News

Ardei iuti

Panou presurizat ACM - probleme

Coordonate sistem Stereo 1970 bra...
 Un sunet ciudat

Firme cuptoare si plite

Raspunderea patrimoniala.

Umiditatea in casa
 Viagra fara sa afle iubita

The Enforcer (2022)

Centrala nu porneste sa incalzeas...

Strategii de trading. Crypto sau ...
 Lipsa sunet pe OSX dar funcț...

GOLF 5 1.9 TDI BXF 90CP

Display Asus ROG Strix G15 2021

Sfat achizitie Volvo XC40 (Volvo ...
 

Timer sau Sleep WFA

- - - - -
  • Please log in to reply
32 replies to this topic

#1
reddevilnb1

reddevilnb1

    Senior Member

  • Grup: Senior Members
  • Posts: 2,246
  • Înscris: 13.12.2007
Salut.
Am nevoie de putin ajutor cu un proiect.Proiectul este facut in Visual Studio 2010 in WFA.Am scris deja codul insa am nevoie de un timer sau de functia sleep si nu stiu sa implementez nici una din aceste functii.Deci as vrea ca dupa un anumit sir de instructiuni sa am un delay de 1 secunda  pana la executarea urmatoarei instructiuni.Eu de obicei fac doar programe in consola si nu stiu prea multe in WFA.Putin ajutor va rog.Multumesc Posted Image

#2
neagu_laurentiu

neagu_laurentiu

    Guru Member

  • Grup: Senior Members
  • Posts: 39,843
  • Înscris: 30.07.2003
System.Threading.Thread.Sleep(milliseconds)
http://msdn.microsof...y/d00bd51t.aspx

#3
reddevilnb1

reddevilnb1

    Senior Member

  • Grup: Senior Members
  • Posts: 2,246
  • Înscris: 13.12.2007
am incercat insa numai erori am primit dupa ce am scris System.Threading.Thread.Sleep(1000);
>f:\project\project4\project4\Form1.h(265): error C2065: 'system' : undeclared identifier
1>f:\project\project4\project4\Form1.h(265): error C2228: left of '.Threading' must have class/struct/union
1>   type is ''unknown-type''
1>f:\project\project4\project4\Form1.h(265): error C2228: left of '.Thread' must have class/struct/union
1>f:\project\project4\project4\Form1.h(265): error C2228: left of '.Sleep' must have class/struct/union
1>f:\project\project4\project4\Form1.h(268): error C2065: 'system' : undeclared identifier
1>f:\project\project4\project4\Form1.h(268): error C2228: left of '.Threading' must have class/struct/union
1>   type is ''unknown-type''
1>f:\project\project4\project4\Form1.h(268): error C2228: left of '.Thread' must have class/struct/union
1>f:\project\project4\project4\Form1.h(268): error C2228: left of '.Sleep' must have class/struct/union
1>f:\project\project4\project4\Form1.h(273): error C2065: 'system' : undeclared identifier
1>f:\project\project4\project4\Form1.h(273): error C2228: left of '.Threading' must have class/struct/union
1>   type is ''unknown-type''
1>f:\project\project4\project4\Form1.h(273): error C2228: left of '.Thread' must have class/struct/union
1>f:\project\project4\project4\Form1.h(273): error C2228: left of '.Sleep' must have class/struct/union
1>f:\project\project4\project4\Form1.h(276): error C2065: 'system' : undeclared identifier
1>f:\project\project4\project4\Form1.h(276): error C2228: left of '.Threading' must have class/struct/union
1>   type is ''unknown-type''
1>f:\project\project4\project4\Form1.h(276): error C2228: left of '.Thread' must have class/struct/union
1>f:\project\project4\project4\Form1.h(276): error C2228: left of '.Sleep' must have class/struct/union

#4
neagu_laurentiu

neagu_laurentiu

    Guru Member

  • Grup: Senior Members
  • Posts: 39,843
  • Înscris: 30.07.2003
Postezi pe aria VB si ai cod C++/CLI ?!
System::Threading::Thread::Sleep(milliseconds);

Edited by neagu_laurentiu, 29 December 2012 - 16:47.


#5
reddevilnb1

reddevilnb1

    Senior Member

  • Grup: Senior Members
  • Posts: 2,246
  • Înscris: 13.12.2007
Visual Basic nu e tot una cu Visual Studio?

#6
neagu_laurentiu

neagu_laurentiu

    Guru Member

  • Grup: Senior Members
  • Posts: 39,843
  • Înscris: 30.07.2003
Nu.
Visual Studio contine: Visual Basic, Visual C++, Visual C#

#7
reddevilnb1

reddevilnb1

    Senior Member

  • Grup: Senior Members
  • Posts: 2,246
  • Înscris: 13.12.2007
Multumesc pentru raspunsuri Posted Image

#8
neagu_laurentiu

neagu_laurentiu

    Guru Member

  • Grup: Senior Members
  • Posts: 39,843
  • Înscris: 30.07.2003
Pune cum ti-am aratat mai sus in sitaxa C++/CLI.
Si nu uita:
The following project templates no longer exist:
    Windows Forms Application
    Windows Forms Control Library
Although we recommend that you do not create Windows Forms applications in C++/CLI, maintenance of existing C++/CLI UI applications is supported. If you have to create a Windows Forms application, or any other .NET UI application, use C# or Visual Basic. Use C++/CLI for interoperability purposes only.
http://msdn.microsof...y/bb531344.aspx

Edited by neagu_laurentiu, 29 December 2012 - 17:04.


#9
reddevilnb1

reddevilnb1

    Senior Member

  • Grup: Senior Members
  • Posts: 2,246
  • Înscris: 13.12.2007
Deci am pus asa cum mi-ai spus si cand apas pe buton programul se blocheaza.Alta sugestie?:-\
Sau sa trec aici codul si sa il verifici?

Scopul programului ar fi sa coloreze ceva forme si apoi sa redevina formele transparente si tot asa.

private: System::Void button1_Click(System::Object^  sender, System::EventArgs^  e) {
  
this->ovalShape1->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape1->BackColor = System::Drawing::Color::Red;
System::Threading::Thread::Sleep(1000);
this->ovalShape1->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape2->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape2->BackColor = System::Drawing::Color::Lime;
System::Threading::Thread::Sleep(1000);
this->ovalShape2->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape3->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape3->BackColor = System::Drawing::Color::DeepSkyBlue;
System::Threading::Thread::Sleep(1000);
this->ovalShape3->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape4->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape4->BackColor = System::Drawing::Color::Red;
System::Threading::Thread::Sleep(1000);
this->ovalShape4->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape5->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape5->BackColor = System::Drawing::Color::Lime;
System::Threading::Thread::Sleep(1000);
    this->ovalShape5->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape6->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape6->BackColor = System::Drawing::Color::DeepSkyBlue;
System::Threading::Thread::Sleep(1000);
    this->ovalShape6->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape7->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape7->BackColor = System::Drawing::Color::Red;
System::Threading::Thread::Sleep(1000);
this->ovalShape7->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape8->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape8->BackColor = System::Drawing::Color::Lime;
System::Threading::Thread::Sleep(1000);
this->ovalShape8->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape9->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape9->BackColor = System::Drawing::Color::DeepSkyBlue;
System::Threading::Thread::Sleep(1000);
this->ovalShape9->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape10->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape10->BackColor = System::Drawing::Color::Red;
System::Threading::Thread::Sleep(1000);
this->ovalShape10->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape11->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape11->BackColor = System::Drawing::Color::Lime;
System::Threading::Thread::Sleep(1000);
this->ovalShape11->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape12->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape12->BackColor = System::Drawing::Color::DeepSkyBlue;
System::Threading::Thread::Sleep(1000);
this->ovalShape12->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape13->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape13->BackColor = System::Drawing::Color::Red;
System::Threading::Thread::Sleep(1000);
this->ovalShape13->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape14->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape14->BackColor = System::Drawing::Color::Lime;
System::Threading::Thread::Sleep(1000);
this->ovalShape14->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape15->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape15->BackColor = System::Drawing::Color::DeepSkyBlue;
System::Threading::Thread::Sleep(1000);
this->ovalShape15->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape16->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape16->BackColor = System::Drawing::Color::Red;
System::Threading::Thread::Sleep(1000);
this->ovalShape16->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);
this->ovalShape17->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Opaque;
this->ovalShape17->BackColor = System::Drawing::Color::Lime;
System::Threading::Thread::Sleep(1000);
this->ovalShape17->BackStyle = Microsoft::VisualBasic::PowerPacks::BackStyle::Transparent;
System::Threading::Thread::Sleep(500);

    }

#10
neagu_laurentiu

neagu_laurentiu

    Guru Member

  • Grup: Senior Members
  • Posts: 39,843
  • Înscris: 30.07.2003
Pai nu ai vrut sa se blocheze o perioada ?

#11
reddevilnb1

reddevilnb1

    Senior Member

  • Grup: Senior Members
  • Posts: 2,246
  • Înscris: 13.12.2007
deci vroiam ca sa coloreze acea forma->sleep 1 secunda->sa devina transparent->sleep->sa treaca la umratoarea instructiune deci coloreze->sleep->transparent->etc

#12
msmihai

msmihai

    Senior Member

  • Grup: Senior Members
  • Posts: 5,259
  • Înscris: 02.09.2006
Genial. Ai blocat firul de executie GUI. Evident, procesarea mesajelor de la sistemul de operare se opreste si interfata "ingheata".

Edited by msmihai, 29 December 2012 - 17:22.


#13
reddevilnb1

reddevilnb1

    Senior Member

  • Grup: Senior Members
  • Posts: 2,246
  • Înscris: 13.12.2007
si ceva sugestii .....?

#14
msmihai

msmihai

    Senior Member

  • Grup: Senior Members
  • Posts: 5,259
  • Înscris: 02.09.2006
Sa nu-l mai blochezi, evident. N-ai ce cauta cu Thread.Sleep in firul de executie GUI!

Edited by msmihai, 29 December 2012 - 17:34.


#15
neagu_laurentiu

neagu_laurentiu

    Guru Member

  • Grup: Senior Members
  • Posts: 39,843
  • Înscris: 30.07.2003
Nu ai specificat din start ce vrei sa faci ! Ai vrut un Sleep !
Foloseste inainte de Sleep pe Application::DoEvents();
Daca nu trebuie cu timere.

#16
reddevilnb1

reddevilnb1

    Senior Member

  • Grup: Senior Members
  • Posts: 2,246
  • Înscris: 13.12.2007
msmihai daca nu stiu ceva folositor mai bine sa nu spui nimic...
am specificat la inceput "Deci as vrea ca dupa un anumit sir de instructiuni sa am un delay de 1 secunda  pana la executarea urmatoarei instructiuni."
@neagu_laurentiu nu stiu sa fac timer ....

Edited by reddevilnb1, 29 December 2012 - 17:40.


#17
msmihai

msmihai

    Senior Member

  • Grup: Senior Members
  • Posts: 5,259
  • Înscris: 02.09.2006
Sa traiti' domn' capitan, nu mai spun nimic. Da-i cu Thread.Sleep in continuare. De fapt, da-i direct in main-ul aplicatiei, inainte de initializarea GUI.

#18
neagu_laurentiu

neagu_laurentiu

    Guru Member

  • Grup: Senior Members
  • Posts: 39,843
  • Înscris: 30.07.2003

View Postreddevilnb1, on 29 decembrie 2012 - 17:36, said:

am specificat la inceput "Deci as vrea ca dupa un anumit sir de instructiuni sa am un delay de 1 secunda  pana la executarea urmatoarei instructiuni."
Si asta face foarte bine Sleep. Problema ta e cum pui in context. Se face pauza dar nu are timp in spate pentru schimbarile de culoare sau ce faci acolo. E mai complicat. Dar pauza intre o instructine si alta ai. Nu e buna solutia in contextul tau.

View Postreddevilnb1, on 29 decembrie 2012 - 17:36, said:

nu stiu sa fac timer ....
Hai ca-i plin netul de exemple !

Edited by neagu_laurentiu, 29 December 2012 - 17:45.


Anunturi

Chirurgia spinală minim invazivă Chirurgia spinală minim invazivă

Chirurgia spinală minim invazivă oferă pacienților oportunitatea unui tratament eficient, permițându-le o recuperare ultra rapidă și nu în ultimul rând minimizând leziunile induse chirurgical.

Echipa noastră utilizează un spectru larg de tehnici minim invazive, din care enumerăm câteva: endoscopia cu variantele ei (transnazală, transtoracică, transmusculară, etc), microscopul operator, abordurile trans tubulare și nu în ultimul rând infiltrațiile la toate nivelurile coloanei vertebrale.

www.neurohope.ro

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users

Forumul Softpedia foloseste "cookies" pentru a imbunatati experienta utilizatorilor Accept
Pentru detalii si optiuni legate de cookies si datele personale, consultati Politica de utilizare cookies si Politica de confidentialitate