共 13 篇文章 |
|
图片上传压缩成缩略图的代码。Image myImage = System.Double newWidth = myImage.Width , newHeight = myImage.Width>myImage.Height || myImage.Width==myImage.Height * (newWidth/myImage.newWidth = myImage.Width * (newHeight/myImage.Image bitmap = new System.DrawImage(myImage , new System.Width, bitmap.Width,myImage.DrawIm... 阅791 转8 评0 公众公开 13-11-15 14:06 |
//改为ManualResetEvent,车闸默认关闭 static void Main(string[] args) { new Thread(Car1).Start();//车辆1 new Thread(Car2).Start();//车辆2 _tollStation.Set();//开启车闸,放行 Timer timer = new Timer(CloseDoor, null, 0, 2000);//2秒后关闭车闸 Console.ReadKey(); } static void Car1() { _tollStation.WaitOne();//等待开启车闸,... 阅212 转3 评0 公众公开 13-08-29 14:59 |
阅4873 转86 评0 公众公开 13-08-22 17:56 |
创建、删除、复制文件夹及其子文件。returnStr = "成功创建该文件夹!创建时间为:" + System.IO.Directory.GetCreationTime(argPath);/// 递归删除文件夹及文件。Write(dir + " 该文件夹不存在"); //如果文件夹不存在则提示。/// 实现一个静态方法将指定文件夹下面的所有内容copy到目标文件夹下面。public static void Co... 阅137 转1 评0 公众公开 13-03-20 16:09 |
用正则表达式进行替换Regex regex = new Regex("(/+)"); //匹配至少一个的"/"STR = regex.Replace(STR, "/"); //将字符串中的所有的"/"全部替换成"/" 阅145 转0 评0 公众公开 13-03-18 10:33 |
阅285 转4 评0 公众公开 13-03-01 17:34 |
因为在线程池中有线程的线程处于等待分配任务状态(只要没有超过线程池的最大上限),无需创建线程。Id:964,ProcessName:svchost,StartTime:2010-1-11 8:23:22.Id:1408,ProcessName:svchost,StartTime:2010-1-11 8:23:23.Id:1140,ProcessName:svchost,StartTime:2010-1-11 8:23:22.Id:1028,ProcessName:svchost,StartTime:2010-1-11 8:23:22.Id... 阅178 转1 评0 公众公开 13-03-01 17:33 |
多线程编程(2):线程的同步。首先在 Result(int seed)方法中讲计算基数、第一项、第二项及第三项的方法放到线程池中,要计算第一二三项时首先要确定基数,这些方法通过manualEvent.WaitOne()暂时停止执行,于是计算基数的方法首先执行,计算出基数之后通过manualEvent.Set()方法通知计算第一二三项的方法开始,在这些方法完成计算之后通过autoE... 阅71 转1 评0 公众公开 13-03-01 17:31 |
带参数的启动方法 如果要在实例化线程时要带一些参数,就不能用ThreadStart委托作为构造函数的参数来实例化Thread了,而要ParameterizedThreadStart委托,和ThreadStart一样的是它也是线程启动时要执行的方法,和ThreadStart不同的是,它在实例化时可以用一个带有一个Object参数的方法作为构造函数的参数,而实例化ThreadStart时所用到的方法是... 阅124 转3 评0 公众公开 13-03-01 17:30 |
阅5677 转29 评0 公众公开 12-12-19 11:22 |