IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

C# Discussion :

Thread : Problème remplissage de tableau


Sujet :

C#

  1. #1
    Membre du Club
    Inscrit en
    Mai 2006
    Messages
    98
    Détails du profil
    Informations forums :
    Inscription : Mai 2006
    Messages : 98
    Points : 65
    Points
    65
    Par défaut Thread : Problème remplissage de tableau
    Bonjour,

    je dois développer un logiciel de traitement d'image pour mon projet de fin d'étude.
    On nous a demandé de developper en C# et je ne maitrise pas encore assez le langage.

    Mon problème : J'ai voulais partitionner une image en imagette grâce à une fonction
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    private void partitionImagette1()
            {
                for (int i = 0; i < this.m_dimY; i++)
                    for (int j = 0; j < 330; j++)
                    {
                        this.imagette1.pixelR[i, j] = this.tabImage.pixelR[i , j + 220];
                        this.imagette1.pixelV[i, j] = this.tabImage.pixelV[i, j + 220];
                        this.imagette1.pixelB[i, j] = this.tabImage.pixelB[i, j + 220];
                    }
            }
    Si je lance cette fonction sans thread, pas de soucis l'imagette est bien créée et remplie.

    Par contre, si je lance cette fonction via un thread cela ne marche pas.
    Voici le code :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    this.m_ttImg[0] = new Thread(new ThreadStart(partitionImagette1));
                this.m_ttImg[1] = new Thread(new ThreadStart(partitionImagette2));
                this.m_ttImg[2] = new Thread(new ThreadStart(partitionImagette3));
                this.m_ttImg[3] = new Thread(new ThreadStart(partitionImagette4));
                this.m_ttImg[4] = new Thread(new ThreadStart(partitionImagette5));
                this.m_ttImg[5] = new Thread(new ThreadStart(partitionImagette6));
                this.m_ttImg[6] = new Thread(new ThreadStart(partitionImagette7));
                this.m_ttImg[7] = new Thread(new ThreadStart(partitionImagette8));
                this.m_ttImg[8] = new Thread(new ThreadStart(partitionImagette9));
                this.m_ttImg[9] = new Thread(new ThreadStart(partitionImagette10));
    En utilisant ces threads mes images sont vides...

    Une dernière chose la déclaration de mes variables :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    private Thread[] m_ttImg = new Thread[10];
    CImage imagette1;
    ...
    Merci pour vos futurs aides.

  2. #2
    Membre régulier Avatar de deejay2221
    Profil pro
    Inscrit en
    Janvier 2006
    Messages
    98
    Détails du profil
    Informations personnelles :
    Âge : 35
    Localisation : Canada

    Informations forums :
    Inscription : Janvier 2006
    Messages : 98
    Points : 78
    Points
    78
    Par défaut
    Bonjours,

    Oublierais-tu de démarrer tes Thread?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    this.m_ttImg[0] = new Thread(new ThreadStart(partitionImagette1));
    this.m_ttImg[1] = new Thread(new ThreadStart(partitionImagette2));
    this.m_ttImg[2] = new Thread(new ThreadStart(partitionImagette3));
    this.m_ttImg[3] = new Thread(new ThreadStart(partitionImagette4));
    this.m_ttImg[4] = new Thread(new ThreadStart(partitionImagette5));
    this.m_ttImg[5] = new Thread(new ThreadStart(partitionImagette6));
    this.m_ttImg[6] = new Thread(new ThreadStart(partitionImagette7));
    this.m_ttImg[7] = new Thread(new ThreadStart(partitionImagette8));
    this.m_ttImg[8] = new Thread(new ThreadStart(partitionImagette9));
    this.m_ttImg[9] = new Thread(new ThreadStart(partitionImagette10));
     
    for (int i = 0; i < 10; i++)
        m_ttImg[i].Start();
    Petit conseil.
    En C# tu n'es pas obligé de mettre le mot clé this partout. Seulement quand tu a un ambiguïté de portée ou un conflit de namespace. Ça fait du code plus agréable à regarder

Discussions similaires

  1. [WD17] Problème de remplissage de tableau par programmation
    Par anguetone dans le forum WinDev
    Réponses: 1
    Dernier message: 29/01/2015, 11h33
  2. threads problème pour passer un tableau
    Par royal380 dans le forum C
    Réponses: 11
    Dernier message: 12/05/2011, 00h05
  3. [Débutant] Problème de création et de remplissage de tableau
    Par pinggu dans le forum Collection et Stream
    Réponses: 6
    Dernier message: 24/05/2006, 15h50
  4. Thread--> problème avec ThreadProc
    Par stof dans le forum MFC
    Réponses: 33
    Dernier message: 08/06/2005, 13h47
  5. [JComboBox] Remplissage avec tableau de String
    Par linkit dans le forum Composants
    Réponses: 2
    Dernier message: 26/05/2005, 21h39

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo