Skip to content

Instantly share code, notes, and snippets.

@tomaszguzialek
Last active April 11, 2016 18:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tomaszguzialek/88339cb0d6ab23a049d7d5030933215e to your computer and use it in GitHub Desktop.
Save tomaszguzialek/88339cb0d6ab23a049d7d5030933215e to your computer and use it in GitHub Desktop.
Neo4jClient deadlock
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