|
![](/images/resource/spacer.gif) |
|
สอบถามการ ใช้ backgroundWorker หน่อยครับ winfrom c# |
|
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
เขียนไปถึงไหนแล้วครับ
ไม่เอา Event Show Event Hide ไปไว้ใน backgroundWorker_RunWorkerCompleted ละครับ
เพราะชื่อมันก็บอกอยู่แล้วว่า
backgroundWorker_Dowork ทำงานถูกต้องเสร็จแล้ว
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2016-01-08 08:34:21 |
By :
lamaka.tor |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
![](/images/resource/viewboard_01.gif?v=1001) |
|
|
![](/images/resource/viewboard_03.gif?v=1001) |
![](/images/resource/viewboard_04.gif?v=1001) |
|
แนะนำอีกทางเลือกครับ
threading
โค้ดที่ใช้ก็บ้านๆเหมือนที่เคยใช้
แต่ไม่รู้ทำไมมันไม่รับค่าอื่นนอกจาก object 555
Code (C#)
public static void _login(object obj)
{
string _pass;
string s = (string)((object[])obj)[0];
for (int r = 0; r < symbolKey.Length; r++)
{
_pass = s + symbolKey[r];
WriteToFile(_pass);
System.Threading.Thread.Sleep(100);
}
}
static void login()
{
string str = "";
string[] reg = _KeyReg.Split('_');
List<int> rmin = new List<int>();
for (int i = 0; i < 9; i++)
{
rmin.Add(int.Parse(reg[i]));
}
do
}
ตัวอย่างการเรียกใช้งาน
Code (C#)
new System.Threading.Thread(login).Start();
new System.Threading.Thread(_login).Start(new object[] { str });
เสริมต่อ
ใน void ที่จะเรียกใช้งาน หากมีการวน loop ก็ใส
System.Threading.Thread.Sleep()
ให้มันหน่อยจะได้ไม่ทำงานหนักเกินไป
หากต้องการให้ control ต่างๆ เช่น texbox เซตค่า
ก็ใส่ประมาณนี้ครับ
texbox.Invoke(new Action(() => { texbox.Text = "TOR 5555"; }));
ง๊ายง่าย และ กระชับโค้ดไม่เหมือน backgroundWorker ครับ
|
![](/images/resource/blockviewtopic_01.gif?v=1001) |
![](/images/resource/blockviewtopic_02.gif?v=1001) |
![](/images/resource/blockviewtopic_03.gif?v=1001) |
![](/images/resource/blockviewtopic_04.gif?v=1001) |
Date :
2016-01-08 08:47:34 |
By :
lamaka.tor |
|
![](/images/resource/blockviewtopic_06.gif?v=1001) |
![](/images/resource/blockviewtopic_07.gif?v=1001) |
![](/images/resource/blockviewtopic_08.gif?v=1001) |
![](/images/resource/blockviewtopic_09.gif?v=1001) |
|
|
![](/images/resource/viewboard_06.gif?v=1001) |
![](/images/resource/viewboard_07.gif?v=1001) |
|
![](/images/resource/viewboard_08.jpg?v=1001) |
![](/images/resource/viewboard_09.gif?v=1001) |
|
|
|
![](/images/digitalocean-banner.jpg)
|
Load balance : Server 03
|