begin process at 2010 02 09 19:42:55
  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 :12 238

Auteur : cendretp

Ecrire un message privé
Site perso
Commentaire sur cette source (1)
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 une capture Source .NET (Dotnet) AJOUTER DES BYTES À UN EXECUTABLE par t0fx
Source .NET (Dotnet) COPIER/ COLLER DATAGRID (COPY/PASTE) par jamesbidon
Source avec Zip Source .NET (Dotnet) MECANISME DE SYNCHRONISATION DE THREAD - MONITOR, MUTEX, SEM... par jesusonline
Source .NET (Dotnet) EVENTHANDLERS GÉNÉRIQUES par ricklekebekoi
Source avec Zip Source .NET (Dotnet) TRAITER UN FOREACH EN PARALLÈLE par maitredede

 Sources en rapport avec celle ci

Source avec Zip Source avec une capture Source .NET (Dotnet) CALCUL D'EMPREINTES DE FICHIERS par lex35
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 ?

 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 Problème de thread, socket et form [ par Florynth ] Bon pas très compliqué,j'ai créé un thread qui écoute un portaprès je pèse sur un bouton qui fait connectédonc il créé un socket le connect au port en Pb d'affichage de fenetre et thread... [ par bigflo ] Salut,Je developpe un client de tchat en c#.Mais j'ai quelque pb d'affichage des fenetres de tchat. Explication:Bon, j'ai une treeview et lorsque je d thread en C# [ par karshnod ] Bonjour, je me permet de poster car je suis sur un probleme que je ne comprend pas J'ai une WinForm, qui detecte la navigation sur Ie. J'ai un thread Thread + NetworkStream [ par JuS ] Je vais vous exposer mon problème (c'est un peu long à lire et à comprendre...)Je programme un programme client/serveur.Le client, en C#, communique a pb de mise a jour de base de donnée [ par shinevilkyo ] mon pb ce que je veux faire une mise a jour de ma base mias j ai une erreur ds le code ja i beau essayer je ne trouve pas.je sais juste que l erreur c [C#] Visual 2003 -> Visual 2005 [ par scoubidou944 ] Je suis en train de testerl a version 2005 de Visual .NET Whidbey.Alors, premier prog à lancer et ca plante :( dans mon splash screen.En gros j'ai un Multi threading using TCP and socket [ par gdupasqu ] Bonjour,je suis entrain d'écrire un programme (client et serveur).Le serveur fonctionne comme ceci: 1. Le serveur écoute sur un port fixé. 2. Lorsqu'u Multi Threading en utilisant TCP [ par gdupasqu ] Bonjour,je suis entrain d'écrire un programme (client et serveur).Le serveur fonctionne comme ceci:1. Le serveur écoute sur un port fixé.2. Lorsqu'un Les threads sont lents :-( [ par Fildomen ] salutj'ai un prog (tcpclient) où la rapidité compte vraiment,et j'ai réalisé que quand j'utilise les thread, mon prog devient lent, et quand j'execute


Nos sponsors


Sondage...

Comparez les prix

CalendriCode

Février 2010
LMMJVSD
1234567
891011121314
15161718192021
22232425262728

Consulter la suite du CalendriCode

 
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 : 6,412 sec (4)

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