- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 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
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
namespace WF_Map1
{
public partial class Form1 : Form
{
int count = 0;
public Form1()
{
Control.CheckForIllegalCrossThreadCalls = false;
InitializeComponent();
MoveImg X = new MoveImg(LetsMove);
AsyncCallback cb = new AsyncCallback(End);
IAsyncResult ar = X.BeginInvoke(5, 5, ref pictureBox1, ref count, cb, new object[] { });
}
static void LetsMove(int x, int y, ref PictureBox pic1, ref int count)
{
test:
using (MySqlConnection mysqlConn = new MySqlConnection("Host = localhost; User Id = root; Password = 1234;"))
{
try
{
mysqlConn.Open();
using (MySqlCommand mysqlCmd = new MySqlCommand("use move; SELECT * FROM `move`.`test` LIMIT " + count + ", 1;", mysqlConn))
{
MySqlDataReader Dr = mysqlCmd.ExecuteReader();
while (Dr.Read())
{
if (Convert.ToInt32(Dr["x"]) > 25 && Convert.ToInt32(Dr["y"]) > 25) break;
pic1.Location = new Point(Convert.ToInt32(Dr["x"]), Convert.ToInt32(Dr["y"]));
count++;
}
mysqlCmd.Dispose();
Thread.Sleep(1000);
}
}
catch
{
}
finally
{
mysqlConn.Clone();
}
goto test;
}
}
void End(IAsyncResult ar)
{
MoveImg X = (MoveImg)((AsyncResult)ar).AsyncDelegate;
X.EndInvoke(ref pictureBox1, ref count, ar);
}
delegate void MoveImg(int x, int y, ref PictureBox pic1, ref int count);
}
}