/// <summary> /// This demonstrates Hangfire's job Continuations. /// Every job generates an ID, by using this id with a continuation we can execute another job once the previous one has finished. /// In this example, 'coffee.Prepare(name, pref)' will only be executed after 'cake.Prepare()' returns. /// This uses the same logic as Fire-and-Forget jobs, only chained. /// </summary> private static void CoffeeAndCake() { var(name, pref) = AskNameAndPref(); var coffee = new Cappuccino(); var cake = new CheeseCake(); var cakeJobId = BackgroundJob.Enqueue(() => cake.Prepare(name)); BackgroundJob.ContinueJobWith(cakeJobId, () => coffee.Prepare(name, pref)); Console.WriteLine("Coffee and cake planned!"); }
private void food_Click(object sender, EventArgs e) { Button buttonClicked = sender as Button; int rowIndex = orderDetails.Rows.Add(); var row = orderDetails.Rows[rowIndex]; IFood food; switch (buttonClicked.Name) { case "French Baguette": food = new FrenchBaguette(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.frenchBaguetteStock -= 1; break; case "Soft Bread": food = new SoftBread(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.softBreadStock -= 1; break; case "Apple Smoothy": food = new AppleSmoothy(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.appleSmoothyStock -= 1; break; case "Coke": food = new Coke(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.cokeStock -= 1; break; case "Ham Sandwich": food = new HamSandwich(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.hamSandwichStock -= 1; break; case "Panini": food = new Panini(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.paniniStock -= 1; break; case "Cookie": food = new Cookie(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.cookieStock -= 1; break; case "Cheese Cake": food = new CheeseCake(); row.Cells["item"].Value = buttonClicked.Name; row.Cells["price"].Value = food.price; stock.cheeseCakeStock -= 1; buttonClicked.Text = "Cheese Cake " + stock.cheeseCakeStock; break; } updateTotal(); loadButtonsText(); }