Skip to content

Instantly share code, notes, and snippets.

@AJLeuer
Created October 30, 2016 06:50
Show Gist options
  • Save AJLeuer/13c4ac0240edaf40d70ffe14d2dab49c to your computer and use it in GitHub Desktop.
Save AJLeuer/13c4ac0240edaf40d70ffe14d2dab49c to your computer and use it in GitHub Desktop.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using static System.Console;
class CSLambdaAndThreadExamples {
delegate void TestDelegate(string s);
public static Thread fakeThread(ThreadStart s) {
return null;
}
public static Thread fakeThread(ParameterizedThreadStart ss) {
return null;
}
public static void examples() {
var p = new CSLambdaAndThreadExamples();
var a = new Func<byte, int>(p.foo);
WriteLine("hi");
Func<int, string, bool> f2 = (int x, string s) => { return (s.Length > x); };
Action action0 = () => {; };
Action<int> action1 = (int n) => { string s = n + " " + "World"; WriteLine(s); };
Action<int, bool> action2 = (int n, bool b) => { string s = n + " " + "World"; WriteLine(s); };
Action<object> action3 = (object n) => { string s = n + " " + "World"; WriteLine(s); };
Thread thread0 = new Thread(action0.Invoke);
Thread thread1 = new Thread(doThis);
Thread thread2 = new Thread(start: (object n) => {
string s1 = n + " " + "World";
WriteLine(s1);
});
Thread thread3 = fakeThread(s: action0.Invoke);
Thread thread4 = fakeThread(ss: action3.Invoke);
thread2.Start();
}
public static void doThis()
{
int f = 0;
WriteLine("hi");
return;
}
public int foo(byte b) {
return (int)b;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment