Gabriel Barg

Gabriel Barg

  • NA
  • 14
  • 921

Having a problom with Threads

May 30 2019 8:13 AM
I'm trying to send a random PictureBox to the timer1_tick but I'm having a problem with it...
This is my code by now.
 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Threading;
using System.IO;
using System.Drawing.Imaging;
using System.Drawing.Drawing2D;
using System.Collections;
using System.Globalization;
using System.Resources;
namespace Move_the_Block_Project
{
    public partial class Form1 : Form
    {
        public Form1()
       {
            InitializeComponent();
            PictureBox Arrow_S;
            int n;
            List Arrows = new List(3);
           Arrows.Add(A_Up);
           Arrows.Add(A_Right);
           Arrows.Add(A_Left);
           Arrows.Add(A_Down);
           n = SelectRandom();
           Arrow_S = Arrows[n];
           timer1.Interval = 10;
        }
        public int SelectRandom()
        {
            Random random = new Random();
            int a = random.Next(0, 3);
            return a;
         }
        private void timer1_Tick(object sender, EventArgs e)
        {
            Arrow_S = ????
            Arrow_S.Location = new Point(Arrow_S.Location.X, Arrow_S.Location.Y + 1);
        }
        private void Start_B_Click(object sender, EventArgs e)
        {
            bool press= true;
            if (press == true)
           {
                timer1.Start();
           }
          else
          {
                timer1.Stop();
          }
        }
    }
}

Answers (2)