This file contains hidden or 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
package main | |
import ( | |
common_http "bitusion.com/TradingSimulator/common/net/http" | |
"bitusion.com/TradingSimulator/services/order_command_service/handlers" | |
log "github.com/Sirupsen/logrus" | |
"net/http" | |
_ "net/http/pprof" | |
"os" | |
) |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
) | |
func main() { | |
msg := "Hello World!" | |
This file contains hidden or 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
{ | |
"version": "0.2.0", | |
"configurations": [ | |
{ | |
"name": "Launch main.go", | |
"type": "go", | |
"request": "launch", | |
"mode": "debug", | |
"program": "${workspaceRoot}/.", | |
"env": {}, |
This file contains hidden or 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 HomeController : Controller | |
{ | |
public ActionResult Index() | |
{ | |
var jsonTask = GetJsonDeadLockAsync(new Uri("http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo")); | |
//var jsonTask = GetJsonAsync(new Uri("http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo")); | |
var result = jsonTask.Result.ToString(); // this here blocks the initial thread along with it's context | |
return View(); | |
} | |
This file contains hidden or 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 void Test() | |
{ | |
// Cold Task | |
var t = new Task(() => Console.WriteLine()); | |
// Hot Task | |
t.Start(); //now it's hot | |
var tHot1 = Task.Run(()=>Console.WriteLine()); | |
var tHot2 = GetJsonAsync(new Uri("http://......")); | |
} |
This file contains hidden or 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 async Task WhenAnyWhenAll() | |
{ | |
var t = Task.Run(() => Console.WriteLine()); | |
await Task.WhenAny(t); | |
await Task.WhenAll(t); | |
} |
This file contains hidden or 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 async Task AwaitMultiple() | |
{ | |
var t1 = Task.Run(() => Console.WriteLine()); | |
var t2 = Task.Run(() => Console.WriteLine()); | |
var t3 = Task.Run(() => Console.WriteLine()); | |
var t4 = Task.Run(() => Console.WriteLine()); | |
await t1; | |
await t2; | |
await t3; |
This file contains hidden or 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 async Task SleepTaskDelay() | |
{ | |
Thread.Sleep(1000); | |
//vs | |
await Task.Delay(1000); | |
} |
This file contains hidden or 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 async Task SemaphoreSlim() | |
{ | |
var s = new SemaphoreSlim(1, 1); | |
var entered = await s.WaitAsync(1000); | |
if(entered) | |
{ | |
//actual code | |
} |
This file contains hidden or 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 async Task AwaitAsync() | |
{ | |
await Task.Run(() => Console.WriteLine("")); | |
} | |
public Task AwaitNormal() | |
{ | |
return Task.Run(() => Console.WriteLine("")); | |
} |
OlderNewer