Logo Background

Csharp ile Cross Threading Olayı

  • Written by ElektronikElektronik 1 Yorum Var1 Yorum Comments
    Last Updated: Aralık 21, 2009

    Cross Therad

    Cross- olayı bir önceki makalemizde bahsettiğimiz form üzerinde herhangi bir kontrolü kullanırken bu kontrole ikinci bir kez erişmek istediğimizde yani kanallar içerisinde bulunanan nesnelerin birbiriyle değerlerini değişmesi için Cross ilişkisine azda olsa değinmiştik.
    Bu yazımızda ‘den faydalanarak bu işlemi kolayca kanallar vasıtasıyla yapacağız..
    Programın kodlarına makalenin sonundaki linkten ulaşabilirsiniz..

    ?View Code CSHARP
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Threading;
     
    namespace Cross_thread
    {
        public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
     
            Thread Kanal;
            delegate void labelyaz(string kelime);
            double i = 0;
     
            private void mesajyazdir()
            {
                while (true)
                {
                    islem(i.ToString());
                    i++;
                }
     
            }
     
            private void button1_Click(object sender, EventArgs e)
            {
                Kanal = new Thread(new ThreadStart(mesajyazdir));
                Kanal.Start();
            }
     
            private void islem(string gelen)
            {
                if (this.InvokeRequired)
                {
                    labelyaz yenidelegate = new labelyaz(islem);
                    this.Invoke(yenidelegate, new object[] { gelen });
                }
                else
                    this.Text = gelen;
            }
     
            private void button2_Click(object sender, EventArgs e)
            {
                MessageBox.Show("Www.xdelete.com\n" + i.ToString());
            }
     
     
        }
    }

    Kaynak Dosyaları İndir : C# ile Cross Thread ile Cross Örneklemesi


  • Warning: Unexpected character in input: ''' (ASCII=39) state=1 in /home/xdelete/public_html/forum/cache/data_c1176e3b86b838cc919e441a620ca4b6-SMF-modSettings.php on line 1

    Parse error: syntax error, unexpected ':' in /home/xdelete/public_html/forum/cache/data_c1176e3b86b838cc919e441a620ca4b6-SMF-modSettings.php on line 1