C# 程式設計

基礎篇

C# 簡介

開發環境

變數與運算

流程控制

陣列

函數

物件

例外處理

函式庫篇

檔案處理

資料結構

正規表達式

Thread

應用篇

視窗程式

媒體影音

網路程式

遊戲程式

手機程式

資料庫

雲端運算

特殊功能

委派

擴展方法

序列化

LinQ

WPF

網路資源

教學影片

投影片

教學文章

軟體下載

考題解答

101習題

蔣諸華 (guest) 24 Dec 2012 06:37

老師您好~
我是C#新手, 所以有很多命令寫法仍不熟悉, 我在網路上也試圖找許多寫法但仍未成功, 所以想在此請教您一個問題, 可否請您給一些建議, 謝謝!!
我在程式運行當中想隨時偵測button_Stop 是否被觸發, 我現在使用的程式碼是 :Application.DoEvents();
雖然程式可以運行, 卻仍想試試看是否有其他寫法可行, 不知道老師是否可以給我一點建議, 如能回覆, 非常感謝!!

public partial class Form1:Form
{
private void button_Start_Click(object sender, EventArgs e)//開始測試
{
REG.PMBus_Verify();
}

public void button_Stop_Click(object sender, EventArgs e)//暫停測試
{
ATS_TEST.STOP_FLAG = true;
}
}

class PMBus_Reg
{
public void PMBus_Verify()
{
SEQ_Result = Run_REG();
}

public bool Run_REG()
{
Application.DoEvents(); // 偵測button_Stop_Click是否被觸發
// 以下都是程式碼

}

}

by 蔣諸華 (guest), 24 Dec 2012 06:37
為何不這樣做就好了呢?
ccckmit ccckmit 24 Dec 2012 07:55

public partial class Form1:Form
{
bool isButtonStarted = false;

private void button_Start_Click(object sender, EventArgs e)//開始測試
{
isButtonStarted = true;
}

public void button_Stop_Click(object sender, EventArgs e)//暫停測試
{
isButtonStarted = false;
}
}

by ccckmit ccckmit , 24 Dec 2012 07:55
蔣諸華 (guest) 25 Dec 2012 01:19

你好, 由於是測試軟體, 有需要到中途暫停, 輸入條碼…等功能, 所以無法把所有相關的測試程式碼全部寫在 button_Start 裡, 只能把程式一支支拆掉(測試項目太多)
你的程式碼 bool isButtonStarted = false; 我也有寫, 只是沒寫在網路上, 但這方式無法在中途偵測到button_Stop被觸發, 而是等到測試完才觸發此按鈕, 這樣完全就失去時效性了。還是謝謝你的回覆!!

by 蔣諸華 (guest), 25 Dec 2012 01:19
无言
EndLimitx321 EndLimitx321 22 Apr 2023 11:15

这种免费的不多见了。

by EndLimitx321 EndLimitx321 , 22 Apr 2023 11:15
EndLimitx321 EndLimitx321 22 Apr 2023 11:16

可以单独列一个页面出来讨论而不是全部集中在主页面中的讨论区,可以参考wikidot中流行的各种的小说网站的讨论模式。

by EndLimitx321 EndLimitx321 , 22 Apr 2023 11:16

Post preview:

(will not be published)


本網頁的作者、授權與引用方式

作者
陳鍾誠,於金門大學資訊工程系,電子郵件:wt.ude.uqn|ccc#wt.ude.uqn|ccc,網站:http://ccckmit.wikidot.com
授權
本文採用創作共用 (Creative Common) 3.0 版的 姓名標示─非商業性─相同方式分享 授權條款,歡迎轉載或修改使用,但若做為商業使用時必須取得授權,引用本文時請參考下列格式。
中文版 (APA格式)
陳鍾誠 (10 Jun 2010 00:54),(網頁標題) C# 程式設計,(網站標題) 免費電子書:C# 程式設計,10 Jun 2010 00:54,取自 http://cs0.wikidot.com/main ,網頁修改第 45 版。
英文版 (APA格式)
Chung-Chen Chen (10 Jun 2010 00:54), Retrieved 10 Jun 2010 00:54 from http://cs0.wikidot.com/main, Page Revision 45.
page revision: 45, last edited: 25 Jul 2021 21:13
Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License
Click here to edit contents of this page.
Click here to toggle editing of individual sections of the page (if possible). Watch headings for an "edit" link when available.
Append content without editing the whole page source.
Check out how this page has evolved in the past.
If you want to discuss contents of this page - this is the easiest way to do it.
View and manage file attachments for this page.
A few useful tools to manage this Site.
Change the name (also URL address, possibly the category) of the page.
View wiki source for this page without editing.
View/set parent page (used for creating breadcrumbs and structured layout).
Notify administrators if there is objectionable content in this page.
Something does not work as expected? Find out what you can do.
General Wikidot.com documentation and help section.
Wikidot.com Terms of Service - what you can, what you should not etc.
Wikidot.com Privacy Policy.

AltStyle によって変換されたページ (->オリジナル) /