This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class AsyncCompletion | |
{ | |
private static readonly TaskCompletionSource<Unit> CompletedSource; | |
static AsyncCompletion() | |
{ | |
CompletedSource = new TaskCompletionSource<Unit>(); | |
CompletedSource.SetResult(Unit.Default); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* 引入voidable修饰符,用于修饰泛型参数。 | |
* 被修饰的泛型参数T,可以在代码里具体化为void类型。 | |
*/ | |
class Task<voidable T> { } // 带有voidable修饰 | |
class List<T> { } // 不带voidable修饰 | |
/* |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 添加一个扩展方法 | |
public static class WebClientExtensions { | |
public static Task<string> DownloadStringAsync( | |
this WebClient client, | |
Uri uri, | |
CancellationToken cancellationToken, | |
int timeout) { | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static IEnumerable<TResult> SelectNonNull<TSource, TResult>( | |
this IEnumerable<TSource> source, | |
Func<TSource, TResult> selector) | |
where TResult : class | |
{ | |
return source != null ? source.Select(selector).Where(i => i != null) : Enumerable.Empty<TResult>(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TicksToDateTimeCaller { | |
private static DateTime TicksToDateTime(long ticks) { | |
return new DateTime(ticks); | |
} | |
public TResult Call<T, TResult>(T arg) { | |
return (TResult)(object)TicksToDateTime((long)(object)arg); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[MethodImpl(MethodImplOptions.NoInlining)] | |
static object UseBox(int num) | |
{ | |
return num; | |
} | |
private class IntWrapper | |
{ | |
public int Num; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Window x:Class="WpfApplication1.MainWindow" | |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" | |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" | |
Title="MainWindow" Height="350" Width="525"> | |
<Grid> | |
<Grid.Resources> | |
<ControlTemplate TargetType="DataGridCell" x:Key="TestCell"> | |
<Border Name="PART_CellBorder" SnapsToDevicePixels="True" BorderBrush="Red" BorderThickness="2"> | |
<ContentPresenter Name="PART_ContentPresenter" Content="{Binding}" /> | |
</Border> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Build FAILED. | |
"C:\projects\RazorEngine\RazorEngine-3.6.4\src\RazorEngine.sln" (Build t | |
arget) (1) -> | |
"C:\projects\RazorEngine\RazorEngine-3.6.4\src\test\Test.RazorEngine.Cor | |
e\Test.RazorEngine.Core.csproj" (default target) (3) -> | |
(CoreCompile target) -> | |
IsolatedRazorEngineServiceTestFixture.cs(180,71): error CS0122: 'Razor | |
Engine.Compilation.CompilerServiceBase.DynamicTemplateNamespace' is inac | |
cessible due to its protection level [C:\projects\RazorEngine\RazorEngin |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#light | |
open Microsoft.FSharp.Control | |
let counter = | |
MailboxProcessor.Start(fun inbox -> | |
let rec loop() = | |
async { | |
let! msg = inbox.Scan(fun x -> | |
match x with |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Crawling | |
{ | |
public class Crawler : Actor<Message>, ICrawlingHandler | |
{ | |
protected override void Receive(Message message) | |
{ | |
message(this); | |
} | |
public Crawler(Monitor monitor) |
OlderNewer