2011年11月15日

ThreadingTester

摘要: using System;using System.Threading;namespace ThreadingTester{ class ThreadingTester { public static void trmain() { for (int x = 0; x < 100; x++) { Thread.Sleep(1000); Console.WriteLine(x); } } static void Main(string[] args) { Thread thrd1 = new Thread(new ThreadStart(trmain)); thrd1.Start(); f 阅读全文

posted @ 2011-11-15 22:35 breakpoint 阅读(87) 评论(0) 推荐(0) 编辑

TestGenericClass

摘要: using System;using System.Collections.Generic;namespace ConsoleApplication1{ public interface IAccount { string Name { get; } decimal Balance { get; } } public class Account : IAccount { private string name; public string Name { get { return name; } } private decimal balance; public decimal Balance 阅读全文

posted @ 2011-11-15 22:34 breakpoint 阅读(107) 评论(0) 推荐(0) 编辑

LINQ

摘要: using System;using System.Collections.Generic;using System.Data.Linq;using System.Data.Linq.Mapping;using System.Data.Linq.SqlClient;using System.Linq;using System.IO;namespace ThreadingTester{ [Table(Name = "Customers")] public class Customer { [Column(IsPrimaryKey = true)] public string 阅读全文

posted @ 2011-11-15 22:33 breakpoint 阅读(217) 评论(0) 推荐(0) 编辑

MultiThread

摘要: using System;using System.Threading;namespace MultiThread{ public class Program { static ManualResetEvent mre = new ManualResetEvent(false); static void Main77() { Thread t = new Thread(new ThreadStart(Hello)); t.Start(); while (true) { char a = Console.ReadKey().KeyChar; if (a.ToString().ToUpper() 阅读全文

posted @ 2011-11-15 22:33 breakpoint 阅读(171) 评论(0) 推荐(0) 编辑

Generic

摘要: using System;using System.Collections.Generic;namespace ConsoleApplication1{ class Generic { static void Main11(string[] args) { PrintAll2<int>(3); PrintAll2<string>("c"); PrintAll2(4); PrintAll2("d"); PrintAll2(5.5); Console.ReadLine(); } static void PrintAll2<T&g 阅读全文

posted @ 2011-11-15 22:31 breakpoint 阅读(98) 评论(0) 推荐(0) 编辑

GenericClassInherit

摘要: using System;using System.Collections.Generic;using System.Linq;using System.Text;namespace ConsoleApplication1{ class GenericClassInherit { //C# 编译器只允许将泛型参数隐式强制转换到 Object 或约束指定的类型 public interface ISomeInterface { } class BaseClass { } class MyClass<T> where T : BaseClass, ISomeInterface { vo 阅读全文

posted @ 2011-11-15 22:31 breakpoint 阅读(73) 评论(0) 推荐(0) 编辑

GetURLAsync

摘要: using System;using System.IO;using System.Net;using System.Threading;/// <summary>/// 使用异步机制的例子/// </summary>public class CAsync{ const int MAX = 1024; public static int Main88() { Uri HttpSite; HttpWebRequest wreq; IAsyncResult r; HttpSite = new Uri("http://localhost"); wreq = 阅读全文

posted @ 2011-11-15 22:31 breakpoint 阅读(99) 评论(0) 推荐(0) 编辑

Flower

摘要: using System;using System.Threading;public class TestMain{ private static ManualResetEvent ent = new ManualResetEvent(false); public static void Main33() { Boy sender = new Boy(ent); //Thread th = new Thread(new ThreadStart(sender.SendFlower)); //th.Start(); //ent.WaitOne(); //等待工作 for (int i = 0; . 阅读全文

posted @ 2011-11-15 22:30 breakpoint 阅读(105) 评论(0) 推荐(0) 编辑

BeginInvoke

摘要: using System;using System.Threading;namespace ConsoleApplication1{ class BeginInvoke { private delegate int NewTaskDelegate(int ms); static void Main44() { NewTaskDelegate task = new NewTaskDelegate(newTask);//委托实例 IAsyncResult asyncResult = task.BeginInvoke(2000, new AsyncCallback(CallBackMethod11) 阅读全文

posted @ 2011-11-15 22:29 breakpoint 阅读(409) 评论(0) 推荐(0) 编辑

CalculateTest

摘要: using System;using System.Threading;class CalculateTest{ static void Main11() { Calculate calc = new Calculate(); Console.WriteLine("Result = {0}.",calc.Result(234).ToString()); Console.WriteLine("Result = {0}.",calc.Result(55).ToString()); }}class Calculate{ double baseNumber, f 阅读全文

posted @ 2011-11-15 22:29 breakpoint 阅读(99) 评论(0) 推荐(0) 编辑

导航