Last active
April 11, 2016 18:36
-
-
Save tomaszguzialek/88339cb0d6ab23a049d7d5030933215e to your computer and use it in GitHub Desktop.
Neo4jClient deadlock
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 Neo4jClient; | |
using Nito.AsyncEx; | |
using System; | |
using System.Threading.Tasks; | |
namespace DeadlockDemo | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
Console.WriteLine("Starting the program"); | |
var program = new Program(); | |
AsyncContext.Run(() => program.MainThreadAsync()); | |
Console.WriteLine("Finished the program"); | |
} | |
private async Task MainThreadAsync() { | |
Console.WriteLine("Creating the GraphClient"); | |
var graphClient = new GraphClient(new Uri("http://localhost:7474/db/data")); | |
Console.WriteLine("Connecting to Neo4j"); | |
graphClient.Connect(); | |
Console.WriteLine("Connected to Neo4j"); | |
await addReviewNode(graphClient); | |
} | |
private async Task addReviewNode(GraphClient graphClient) | |
{ | |
ReviewNode reviewNode = new ReviewNode | |
{ | |
Id = "1", | |
Status = "active" | |
}; | |
var reviewId = "1"; | |
Console.WriteLine("First call..."); | |
graphClient.Cypher | |
.Merge("(review:Review {Id: {reviewIdParam}})") | |
.OnCreate() | |
.Set("review = {reviewParam}") | |
.WithParams(new { reviewIdParam = reviewId, reviewParam = reviewNode }) | |
.ExecuteWithoutResults(); | |
Console.WriteLine("First done"); | |
graphClient.Cypher | |
.Merge("(review:Review {Id: {reviewIdParam}})") | |
.OnCreate() | |
.Set("review = {reviewParam}") | |
.WithParams(new { reviewIdParam = reviewId, reviewParam = reviewNode }) | |
.ExecuteWithoutResults(); | |
Console.WriteLine("Here"); | |
Console.ReadKey(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment