Global variable and thread
My program, should do: In other thread write each result to global array. A main thread read from global array and put on screen. 

It't make in Windows Form Aplication. Other question, how show result in textbox step by step. Normaly, all resault is show on the end of a loop. How refresh a Form in everyone move. And how change view in textbox. Normally I see the first number - 1-, I need see last number - 199 - automatically. 

I have eception:

 

>    Warning	1	Field 'WFA_watki.Form1.tab' is never assigned to, and
> will always have its default value null

My code:

    namespace WFA_watki
    {
        public partial class Form1 : Form
        {
            int[] tab; //----- exception -----
            
            void licz()
            {
                int wynik = 0;
                for (int i = 0; i < 100; i++)
                {
                    
                    wynik =+ i;
                    tab[i] = wynik;
    
                }
                
                MessageBox.Show("Fnish thread 1. result: " + wynik);
                
                
            }
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                 Thread watek1 = new Thread(licz);
                 watek1.Start();
    
                 Thread.Sleep(1000);
    
                 for (int i=0; i < 100; i++)
                 {
                     textBox1.Text += tab[i].ToString() + Environment.NewLine;
                 }      
                 
    
            }
    
        }
    }
Global variable and thread
===

My program, should do: In other thread write each result to global array. A main thread read from global array and put on screen. 

It't make in Windows Form Aplication. Other question, how show result in textbox step by step. Normaly, all resault is show on the end of a loop. How refresh a Form in everyone move. And how change view in textbox. Normally I see the first number - 1-, I need see last number - 199 - automatically. 

I have eception:

 

>    Warning	1	Field 'WFA_watki.Form1.tab' is never assigned to, and
> will always have its default value null

My code:

    namespace WFA_watki
    {
        public partial class Form1 : Form
        {
            int[] tab; //----- exception -----
            
            void licz()
            {
                int wynik = 0;
                for (int i = 0; i < 100; i++)
                {
                    
                    wynik =+ i;
                    tab[i] = wynik;
    
                }
                
                MessageBox.Show("Fnish thread 1. result: " + wynik);
                
                
            }
    
            public Form1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                 Thread watek1 = new Thread(licz);
                 watek1.Start();
    
                 Thread.Sleep(1000);
    
                 for (int i=0; i < 100; i++)
                 {
                     textBox1.Text += tab[i].ToString() + Environment.NewLine;
                 }      
                 
    
            }
    
        }
    }