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 sealed class MyObject : IDisposable | |
{ | |
/// <summary> | |
/// Used by the pool. | |
/// </summary> | |
private MyObject _next; | |
// TODO: Add other members here. | |
public static MyObject Create() |
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
static void Main(string[] args) | |
{ | |
int threadId = Task.Run(() => | |
{ | |
CallContext.LogicalSetData("k", 0); | |
Console.WriteLine("Write logical data on thread " + Thread.CurrentThread.ManagedThreadId); | |
return Thread.CurrentThread.ManagedThreadId; | |
}).Result; | |
while (true) |
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
// I'm starting 10 calls at every 50 msec. Each call has a random execution time between 1-19 seconds. | |
// Many times the last answer comes from the 9th call instead of the 10th. | |
// I'm not sure I'm testing it properly. | |
void Main() | |
{ | |
var rand = new Random(); | |
Enumerable.Range(1,10) |
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
using System; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Microsoft.VisualStudio.TestTools.UnitTesting; | |
[TestClass] | |
public class WaitCanTreatInnerExceptionAsOperationCanceledException | |
{ | |
[TestMethod] | |
public void CancellationTokenPassedToStartNew_CanTreatAsOperationCanceledException() |
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
using System; | |
using System.Linq; | |
using System.Threading.Tasks; | |
// Target: .NET 4.5 Client (or Full) | |
// Add a reference to System.Threading.Tasks.Dataflow | |
class Program | |
{ | |
static void Main(string[] args) |
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
using System; | |
using System.Runtime.CompilerServices; | |
using System.Threading.Tasks; | |
/// <summary> | |
/// Provides support for asynchronous lazy initialization. This type is fully threadsafe. | |
/// </summary> | |
/// <typeparam name="T">The type of object that is being asynchronously initialized.</typeparam> | |
public sealed class AsyncLazy<T> | |
{ |
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
Id collision! | |
task.Id == other.Id: True | |
task == other: False |
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
internal class AwaitableMessages | |
{ | |
public static Task<T> NextMessageAsync<T>() | |
{ | |
var tcs = new TaskCompletionSource<T>(); | |
Messenger.Default.Register<T>(null, item => tcs.TrySetResult(item)); | |
return tcs.Task; | |
} | |
} |
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
using System; | |
using System.Collections.Generic; | |
using System.Diagnostics; | |
using System.Linq; | |
using System.Reflection; | |
using System.Threading.Tasks; | |
namespace DisplayAsyncAPIs | |
{ | |
class Program |
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
java.lang.RuntimeException: org.apache.cxf.interceptor.Fault: Could not send Message. | |
org.apache.cxf.interceptor.AbstractFaultChainInitiatorObserver.onMessage(AbstractFaultChainInitiatorObserver.java:110) | |
org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:323) | |
org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:123) | |
org.apache.cxf.transport.http.AbstractHTTPDestination.invoke(AbstractHTTPDestination.java:207) | |
org.apache.cxf.transport.servlet.ServletController.invokeDestination(ServletController.java:213) | |
org.apache.cxf.transport.servlet.ServletController.invoke(ServletController.java:154) | |
org.apache.cxf.transport.servlet.CXFNonSpringServlet.invoke(CXFNonSpringServlet.java:126) | |
org.apache.cxf.transport.servlet.AbstractHTTPServlet.handleRequest(AbstractHTTPServlet.java:185) | |
org.apache.cxf.transport.servlet.AbstractHTTPServlet.doGet(AbstractHTTPServlet.java:113) |
OlderNewer