線程終止問題

http://topic.csdn.net/u/20080429/09/9cfe5204-20b5-40fb-ac12-afdc1e4939e9.html?590511460?

線程終止問題

http://blog.csdn.net/wuyazhe/article/details/1771470

?帶有消息機制的線程 - CustomMessageQueue(c#)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;namespace CustomMessageQueue_CSharp
{public partial class Form1 : Form{public Form1(){InitializeComponent();}private CustomMessageQueue myMsgQueue;private bool CustomMessageProc(ref CustomMessage m){if (m.Message == 1){MessageBox.Show("我攔截到 id = 1 的消息了。并且,就到此為止了。呵呵");return true;}else{MessageBox.Show(m.Message.ToString());}return false;}private void Button1_Click(object sender, EventArgs e){CustomMessage msg = new CustomMessage();msg.Message = 1;msg.param = "我的自定義消息 ID:1";CustomMessageQueue.PostMessage(ref myMsgQueue, ref msg);}private void Button2_Click(object sender, EventArgs e){CustomMessage msg = new CustomMessage();msg.Message = 2;myMsgQueue.PostMessage(ref msg);}private void Form1_Load(object sender, EventArgs e){myMsgQueue = new CustomMessageQueue();myMsgQueue.StartThread();myMsgQueue.PerTranslateMessage = new CustomMessageQueue.PerTranslateMessageHandler(CustomMessageProc);}private void Form1_FormClosing(object sender, FormClosingEventArgs e){myMsgQueue.PostQuitMessage();}}自定義消息隊列線程
}

  上面是完整的一個程序,包括調用和實現。如果自己使用,可以創建個新的c#工程,添加2個按鈕,復制代碼即可。

轉載于:https://www.cnblogs.com/carl2380/archive/2012/09/17/2688590.html

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/377212.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/377212.shtml
英文地址,請注明出處:http://en.pswp.cn/news/377212.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

HTH的完整形式是什么?

HTH:希望這個(那個)有幫助 (HTH: Hope This (That) Helps) HTH is an abbreviation of "Hope This (That) Helps". HTH是“希望有幫助”的縮寫 。 It is an expression, which is commonly used in messaging or chatting on social media networking si…

排序算法復習—希爾排序

希爾排序,也稱遞減增量排序算法,是插入排序的一種更高效的改進版本。 希爾排序將整個待排元素序列分割成若干個子序列(由相隔某個“增量”的元素組成的)分別進行直接插入排序,過程中較小的元素,跳躍式的往前…

《MySQL——幻讀與next-key lock與間隙鎖帶來的死鎖》

create table t (id int(11) not null,c int(11) default null,d int(11) default null,primary key (id),key c (c) ) engine InnoDB;insert into t values(0,0,0),(5,5,5),(10,10,10),(15,15,15),(20,20,20),(25,25,25);該表除了主鍵id,還有索引c。 問下面的語句…

css 陰影 效果_CSS陰影效果

css 陰影 效果CSS中的陰影效果 (Shadow Effects in CSS) It is always good to make our web pages stylish and beautiful, web pages that would catch users eyes instantly but one gets confused as to how to style his or her web page. The confusion is quite legit t…

java常見的ClassNotFoundException-----菜鳥學習java

java常見的ClassNotFoundException 1 - java.lang.ClassNotFoundException: org.apache.commons.logging.LogFactory 添加包common-logging.jar2 - java.lang.ClassNotFoundException: javax.transaction.Synchronization 添加包jta.jar(hiberante)3 - java.lang.ClassNo…

關于easyui的一些小知識點(1)

讓layout布局自動適應瀏覽器寬度只需要加上fit"true"屬性。轉載于:https://www.cnblogs.com/haifg/p/3613789.html

《MySQL——加鎖規則(待補全,有些沒看懂)》

catalog加鎖規則等值查詢間隙鎖非唯一索引等值鎖主鍵索引范圍鎖非唯一索引范圍鎖唯一索引范圍鎖 bug非唯一索引上存在"等值"的例子limit語句加鎖關于死鎖總結 1、查詢過程中訪問到的對象才會加鎖,而加鎖的基本單位是next-key lock(前開后閉&am…

c# 命名空間命名規范_C#中的命名空間

c# 命名空間命名規范C#命名空間 (C# Namespace ) In C# namespaces are used to group similar type of classes. Two classes with same name in different namespaces never conflict to each other. 在C#中,名稱空間用于對相似類型的類進…

PHP環境搭建:Windows 7下安裝配置PHP+Apache+Mysql環境教程

這兩天剛裝好Windows 7,碰巧前段時間有朋友問我Windows下如何安裝搭建PHP環境,所以打算勤勞下,手動一步步搭建PHP環境,暫且不使用PHP環境搭建軟件了,在此詳細圖解在Windows 7下安裝配置PHPApacheMysql環境的教程&#…

《MySQL—— 業務高峰期的性能問題的緊急處理的手段 》

catalog短連接風暴先處理占著連接但是不工作地線程減少連接過程的消耗慢查詢性能問題索引沒有設計好語句沒寫好選錯索引QPS突增問題短連接風暴 正常的短連接: 執行很少sql語句就斷開,下次需要的時候再重連。MySQL建立連接的過程成本很高,包含…

sql 算出下級銷售總和_找出總和字符串

sql 算出下級銷售總和Description: 描述: This is a standard interview problem to check that the given string is a sum string or not using backtracking. 這是一個標準的面試問題,用于檢查給定的字符串是否為總和字符串或不使用回溯。 Problem…

Request 分別獲取具有相同 name 屬性表單元素值

html 中是允許多個具有相同name屬性的元素的&#xff0c;例如 <div> <input name"txtName" id"txtFirstName" type"text" /> <input name"txtName" id"txtMiddleName" type"text" /> <input…

《MySQL——redo log 與 binlog 寫入機制》

目錄binlog寫入機制redo log寫入機制組提交機制實現大量的TPS理解WAL機制如何提升IO性能瓶頸WAL機制告訴我們&#xff1a;只要redo log與binlog保證持久化到磁盤里&#xff0c;就能確保MySQL異常重啟后&#xff0c;數據可以恢復。 下面主要記錄一下MySQL寫入binlog和redo log的…

BBIAB的完整形式是什么?

BBIAB&#xff1a;再回來一點 (BBIAB: Be Back In A Bit) BBIAB is an abbreviation of "Be Back In A Bit". BBIAB是“ Be Back in A Bit”的縮寫 。 It is an expression, which is commonly used in messaging or chatting on social media networking sites lik…

字符串:KMP Eentend-Kmp 自動機 trie圖 trie樹 后綴樹 后綴數組

涉及到字符串的問題&#xff0c;無外乎這樣一些算法和數據結構&#xff1a;自動機 KMP算法 Extend-KMP 后綴樹 后綴數組 trie樹 trie圖及其應用。當然這些都是比較高級的數據結構和算法&#xff0c;而這里面最常用和最熟悉的大概是kmp&#xff0c;即使如此還是有相當一部分人也…

WPF CanExecuteChanged

繼承ICommand ,RelayCommand命令 1 public class RelayCommand : ICommand2 {3 private readonly Action _execute;4 private readonly Func<bool> _canExecute;5 public event EventHandler CanExecuteChanged;6 public RelayComma…

《MySQL——主備一致性六問六答》

目錄備庫為什么要設置為只讀模式&#xff1f;備庫設置為只讀&#xff0c;如何與主庫保持同步更新&#xff1f;A到B的內部流程如何&#xff1f;binlog內容是什么&#xff1f;row格式對于恢復數據有何好處M-M結構的循環復制問題以及解決方案備庫為什么要設置為只讀模式&#xff1…

代碼管理工具

http://blogs.msdn.com/b/visualstudio/archive/2012/06/11/world-of-samples-at-your-fingertips.aspx轉載于:https://www.cnblogs.com/hebeiDGL/archive/2012/09/25/2700961.html

fyi 在郵件里是什么意思_FYI的完整形式是什么?

fyi 在郵件里是什么意思僅供參考&#xff1a;供您參考 (FYI: For Your Information) FYI is an acronym of "For Your Information". It is a widespread internet slang used these days in text messaging, instant messaging, and chatting on Facebook, WhatsApp…

Hyper-V 替換 vmwp

要激活 Hyper-V 下的虛機 最簡單的方法是用帶證書的vmwp替換掉原來的 帶證書的vmwp參見&#xff1a;http://bbs.pcbeta.com/viewthread-1408240-1-1.html 下載后腰替換 先把 Hyper-V 的倆服務停止掉 然后找到 C:\Windows\System32\vmwp.exe 右鍵--安全 替換掉所有者 然后給自己…