随笔分类 -  CSHARP

摘要:"https://canbefree.github.io/" 阅读全文
posted @ 2016-11-01 10:55 UCanBeFree 阅读(132) 评论(0) 推荐(0)
摘要:使用ApplicationContextstatic class Program { internal static ApplicationContext context = new ApplicationContext(new Form1()); /// /// 应用程序的主入口点。 /// [STAThread] static void Main() { Application.EnableVisualStyles(); ... 阅读全文
posted @ 2014-01-18 14:05 UCanBeFree 阅读(109) 评论(0) 推荐(0)
摘要://----------------线程传多个参数------------------- private void ShowName(object li){ List list= li as List; if (list != null) { foreach (string l in list) { MessageBox.Show(l); } } } private void button1_Click(object se... 阅读全文
posted @ 2014-01-17 15:43 UCanBeFree 阅读(131) 评论(0) 推荐(0)
摘要:public delegate void MyInvoke( ); public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Thread th = new Thread(new ThreadStart(correctfunc)); t... 阅读全文
posted @ 2014-01-02 17:12 UCanBeFree 阅读(167) 评论(0) 推荐(0)
摘要://灵活使用别名使代码更加精简。 using ZClass2 = ZClass, string>; class XClass { //泛型方法 public static void MethodA(z param) { Console.Write(param.GetType().ToString()); } } class YClass { public T MethodA() { T t=default(T); return t; ... 阅读全文
posted @ 2013-12-31 09:09 UCanBeFree 阅读(204) 评论(0) 推荐(0)
摘要:using Temptest = Temptest; class Program { static void Main(string[] args) { Temptest x = new Temptest(); x.func(); //输出: //ConsoleApplication5.Temptest`1[System.String] Console.Read(); } } class Temptest { ... 阅读全文
posted @ 2013-12-31 09:07 UCanBeFree 阅读(226) 评论(0) 推荐(0)
摘要:C++#include "stdafx.h"#include#includeusing namespace std;//声明一个函数结构。typedef void (*func)(string);/***用c++模拟实现委托 * *委托其实就是传递函数指针。 */void fu... 阅读全文
posted @ 2013-12-30 11:47 UCanBeFree 阅读(684) 评论(0) 推荐(0)
摘要:利用线程解决窗口假死基本理论:1,.net2.0以后,CLR默认不允许以非UI线程访问控件。在Framework1.x中,CLR允许应用程序以跨线程的方式运行,而在Framework2.0及以后版本中,System.Windows.Form.Control新增了CheckForIllegalCrossThreadCalls属性,它是一个可读写的bool常量,标记我们是否需要对非UI线程对控件的调用做出检测。如果指定true,当以其他线程访问UI,CLR会跑出一个”InvalidOperationException:线程间操作无效,从不是创建控件***的线程访问它”;如果为false,则不对该错 阅读全文
posted @ 2013-12-29 11:27 UCanBeFree 阅读(252) 评论(0) 推荐(0)