begin process at 2012 02 08 03:54:59
  Trouver un code source :
 
dans
 
Accueil > 

Code

 > 

Astuces

 > BARRE DE STATUT ET DE PROGRESSION COMPATIBLE MULTITHREAD

BARRE DE STATUT ET DE PROGRESSION COMPATIBLE MULTITHREAD


 Information sur la source

Note :
8 / 10 - par 1 personne
8,00 / 10

  • 1

  • 2

  • 3

  • 4

  • 5

  • 6

  • 7

  • 8

  • 9

  • 10
Catégorie :Astuces Source .NET ( DotNet ) Classé sous :progessbar, thread, status, invoke Niveau :Débutant Date de création :02/01/2006 Date de mise à jour :04/01/2006 06:52:28 Vu :14 560

Auteur : cendretp

Ecrire un message privé
Site perso
Commentaire sur cette source (2)
Ajouter un commentaire et/ou une note

 Description

Exemple de gestion de la barre de statut d'un formulaire compatible Multi-thread en Visual Studio 2005

Source

  • public FormGP()
  • {
  • InitializeComponent();
  • // Gestion de la barre de progression
  • ProgressBarAffiDelagate = new ProgressBarAffiDelagateDef(ProgressBarAffi);
  • ProgressBarTimer = new System.Windows.Forms.Timer();
  • // La progress barre à 100% reste 2.5 secondes
  • ProgressBarTimer.Interval = 2500;
  • ProgressBarTimer.Tick += new EventHandler(ProgressBarTimer_Tick);
  • this.ProgressBarValue = -1;
  • // Gestion du Status Label
  • StatusLabelAffiDelagate = new StatusLabelAffiDelagateDef(StatusLabelAffi);
  • StatusLabelTimer = new System.Windows.Forms.Timer();
  • // L'affichage du texte reste 5s
  • StatusLabelTimer.Interval = 5000;
  • StatusLabelTimer.Tick += new EventHandler(StatusLabelTimer_Tick);
  • this.StatusLabelValue = "";
  • }
  • #region Gestion de la barre de progression
  • private delegate void ProgressBarAffiDelagateDef(int pValue);
  • private ProgressBarAffiDelagateDef ProgressBarAffiDelagate;
  • private System.Windows.Forms.Timer ProgressBarTimer;
  • private void ProgressBarAffi(int pValue)
  • {
  • if (!this.toolStripProgressBar1.IsDisposed)
  • {
  • if (pValue < 0)
  • {
  • this.toolStripProgressBar1.Value = 0;
  • this.toolStripProgressBar1.Visible = false;
  • }
  • else
  • {
  • this.toolStripProgressBar1.Visible = true;
  • if (pValue >= 100)
  • {
  • this.toolStripProgressBar1.Value = 100;
  • this.ProgressBarTimer.Start();
  • }
  • else
  • this.toolStripProgressBar1.Value = pValue;
  • }
  • }
  • }
  • void ProgressBarTimer_Tick(object sender, EventArgs e)
  • {
  • this.ProgressBarValue = -1;
  • }
  • /// <summary>
  • /// Valeur de la barre de progression multithread (-1) pour l'effacer
  • /// </summary>
  • public int ProgressBarValue
  • {
  • set
  • {
  • if (this.statusStrip1.InvokeRequired)
  • this.statusStrip1.Invoke(ProgressBarAffiDelagate, value);
  • else
  • ProgressBarAffiDelagate(value);
  • }
  • get
  • {
  • return this.toolStripProgressBar1.Value;
  • }
  • }
  • #endregion
  • #region Gestion du Status Label
  • private delegate void StatusLabelAffiDelagateDef(String pValue);
  • private StatusLabelAffiDelagateDef StatusLabelAffiDelagate;
  • private System.Windows.Forms.Timer StatusLabelTimer;
  • private void StatusLabelAffi(String pValue)
  • {
  • if (!this.toolStripStatusLabel1.IsDisposed)
  • {
  • this.StatusLabelTimer.Start();
  • this.toolStripStatusLabel1.Text = pValue;
  • }
  • }
  • void StatusLabelTimer_Tick(object sender, EventArgs e)
  • {
  • this.toolStripStatusLabel1.Text = "";
  • }
  • /// <summary>
  • /// Valeur Informative compatible multithread dans la barre de Status (Effacement automatique au bout de 5s)
  • /// </summary>
  • public String StatusLabelValue
  • {
  • set
  • {
  • if (this.statusStrip1.InvokeRequired)
  • this.statusStrip1.Invoke(StatusLabelAffiDelagate, value);
  • else
  • StatusLabelAffi(value);
  • }
  • get
  • {
  • return this.toolStripStatusLabel1.Text;
  • }
  • }
  • #endregion
        public FormGP()
        {
            InitializeComponent();
            // Gestion de la barre de progression
            ProgressBarAffiDelagate = new ProgressBarAffiDelagateDef(ProgressBarAffi);
            ProgressBarTimer = new System.Windows.Forms.Timer();
            // La progress barre à 100% reste 2.5 secondes
            ProgressBarTimer.Interval = 2500;
            ProgressBarTimer.Tick += new EventHandler(ProgressBarTimer_Tick);
            this.ProgressBarValue = -1;

            // Gestion du Status Label
            StatusLabelAffiDelagate = new StatusLabelAffiDelagateDef(StatusLabelAffi);
            StatusLabelTimer = new System.Windows.Forms.Timer();
            // L'affichage du texte reste 5s
            StatusLabelTimer.Interval = 5000;
            StatusLabelTimer.Tick += new EventHandler(StatusLabelTimer_Tick);
            this.StatusLabelValue = "";
        }


        #region Gestion de la barre de progression

        private delegate void ProgressBarAffiDelagateDef(int pValue);
        private ProgressBarAffiDelagateDef ProgressBarAffiDelagate;
        private System.Windows.Forms.Timer ProgressBarTimer;

        private void ProgressBarAffi(int pValue)
        {
            if (!this.toolStripProgressBar1.IsDisposed)
            {
                if (pValue < 0)
                {
                    this.toolStripProgressBar1.Value = 0;
                    this.toolStripProgressBar1.Visible = false;
                }
                else
                {
                    this.toolStripProgressBar1.Visible = true;
                    if (pValue >= 100)
                    {
                        this.toolStripProgressBar1.Value = 100;
                        this.ProgressBarTimer.Start();
                    }
                    else
                        this.toolStripProgressBar1.Value = pValue;
                }
            }
        }
        void ProgressBarTimer_Tick(object sender, EventArgs e)
        {
            this.ProgressBarValue = -1;
        }

        /// <summary>
        /// Valeur de la barre de progression multithread (-1) pour l'effacer
        /// </summary>
        public int ProgressBarValue
        {
            set
            {
                if (this.statusStrip1.InvokeRequired)
                    this.statusStrip1.Invoke(ProgressBarAffiDelagate, value);
                else
                    ProgressBarAffiDelagate(value);
            }
            get
            {
                return this.toolStripProgressBar1.Value;
            }

        }
        #endregion

        #region Gestion du Status Label

        private delegate void StatusLabelAffiDelagateDef(String pValue);
        private StatusLabelAffiDelagateDef StatusLabelAffiDelagate;
        private System.Windows.Forms.Timer StatusLabelTimer;

        private void StatusLabelAffi(String pValue)
        {
            if (!this.toolStripStatusLabel1.IsDisposed)
            {
                this.StatusLabelTimer.Start();
                this.toolStripStatusLabel1.Text = pValue;
            }
        }

        void StatusLabelTimer_Tick(object sender, EventArgs e)
        {
            this.toolStripStatusLabel1.Text = "";
        }

        /// <summary>
        /// Valeur Informative compatible multithread dans la barre de Status (Effacement automatique au bout de 5s)
        /// </summary>
        public String StatusLabelValue
        {
            set
            {
                if (this.statusStrip1.InvokeRequired)
                    this.statusStrip1.Invoke(StatusLabelAffiDelagate, value);
                else
                    StatusLabelAffi(value);
            }
            get
            {
                return this.toolStripStatusLabel1.Text;
            }
        }
        #endregion



 Historique

04 janvier 2006 06:52:28 :
Ajout des mots clefs

 Sources du même auteur

Source avec Zip Source avec une capture Source .NET (Dotnet) GÉOLOCALISATION
Source .NET (Dotnet) LABEL DÉFILANT
Source avec Zip Source avec une capture Source .NET (Dotnet) TRANSFERT DE MP3 VERS LECTEUR.

 Sources de la même categorie

Source avec Zip Source .NET (Dotnet) DIFFÉRENTIELLE ENTRE DEUX COLLECTION par morphey_83
Source avec Zip Source avec une capture Source .NET (Dotnet) RICHTEXTBOX POUR COLORATION SYNTAXIQUE EN TEMPS REEL par Renfield
Source avec Zip Source avec une capture Source .NET (Dotnet) TRANSFORMER UN PROGRAMME EN SERVICE par xavh44
Source avec Zip Source .NET (Dotnet) [C# ET T4] TEMPLATE DE VIEW MODEL POUR LE PATTERN MVVM par Kite37
Source .NET (Dotnet) EXEMPLE D'UTILISATION D'UN OCX SANS DECLARATION PREALABLE DA... par yohan49

 Sources en rapport avec celle ci

Source avec Zip Source .NET (Dotnet) AFFICHAGE DE VALEUR PROVENANT D'U THREAD DANS UN FORMULAIRE par Nyuki
Source avec Zip Source .NET (Dotnet) THREADER SIMPLEMENT UNE CLASSE POUR INTERAGIR AVEC UNE FORM par Yxion
Source avec Zip Source avec une capture Source .NET (Dotnet) THREAD ET PROGRESSBAR - EXEMPLE SIMPLE par MorpionMx
Source avec Zip Source .NET (Dotnet) MODIFICATION DE LA VALEUR D'UN CONTROLE À L'INTERIEUR D'UN T... par bestouinouin
Source .NET (Dotnet) EXEMPLE D'UTILISATION DE CONTROL.INVOKE par coq

Commentaires et avis

Commentaire de sebmafate le 02/01/2006 12:23:59 administrateur CS

une petite capture ? des mots clés ?

Commentaire de kahrakib le 27/05/2010 15:20:14

mzerci

 Ajouter un commentaire


Discussions en rapport avec ce code source dans le forum

Ajout d'un contrôle depuis un thread en utilisant Invoke... [ par gazous ] Bonjour,Je vous contacte car j'ai vu que vous étiez assez calé en dll.Mon problème :J'ai un thread qui essaye d'ajouter un contrôle dans un panel char Thread, class et objets [ par thebigboss ] Bonjour, J'ai un programme avec une mainform qui appelle une class. J'ai une progressbar dans ma mainform et un thread qui la fait avancer (à l'aide Cross-thread problème [ par winny68 ] Bonjour, j'ai un problème de compréhension pour réaliser un cross-thread via l'invoke. j'ai vu qu'il y a deux manières de faire un appel; Acti Empêcher multiples threads [ par ansizak ] Bonjour, Je travaille sur un code qui génère des graphes. La génération du graph s'effectue dans un thread afin de permettre l'utilisation du reste d Deux thread acces à un objet [ par rikoukiki ] Bonjour J'ai crée une classe qui permet de mettre à jours une base de données. L'objet de cette classe est lancé dans un thread séparé ou par des mét thread [ par bouleetbil ] Je cree un chat avec des sockets donc j'ai un thread qui tourne en fond de tache et qui recupere les messages. A partir de ce thread je peux recevoir multi thread [ par matt2 ] salut j'aurai besoin d'un renseignement!!!!j'ai créé un prog en multi thread. Chacun des deux thread fait appel à une file que j'ai déclaré dans ma cl ][ PROGESSBAR ][ (app C#) [ par PiAire ] Voilà mon problème :J'ai une dizaine de requêtes qui s'enchaînent les unes à la suite des autres. Elles extraient des données dans des tables qui cont Probleme multithreading Invoke etc. [ par tarkil ] Bonjour,J'ai un petit problème et j'espere que quelqu'un pourra m'aider.Je suis dans ma fenetre principale.Je lance un thread A.Depuis ce thread A, je Changement de langue d'un ColorDialog C# [ par Did69 ] Hello all,Voila mon probleme, lorsqu'on ouvre un ColorDialog, il utilise la langue de windows, en gros si windows est en francais tous les boutons son


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2012
LMMJVSD
  12345
6789101112
13141516171819
20212223242526
272829    

Consulter la suite du CalendriCode

Photothèque

 
Développement réalisé par Nicolas SOREL (Nix) avec l'aide de : Cyril DURAND et Emmanuel (EBArtSoft), Merci à Vincent pour ses précieux conseils.
CodeS-SourceS.com© Toute reproduction même partielle est interdite sauf accord écrit du Webmaster
CodeS-SourceS.com© est une marque déposée tous droits réservés

Google Coop CodeS-SourceS Google Coop CodeS-SourceS
Temps d'éxécution de la page : 0,484 sec (4)

Nous contacter | Annoncer sur CodeS-SourceS | Mentions légales