예제 #1
0
        public async Task TransactionScopeIntroOrRefresh()
        {
            var slide = new Slide(title: "Transaction Scope Intro");
            await slide
                .BulletPoint("System.Transactions.TransactionScope")
                .BulletPoint("Implicit programing model / Ambient Transactions")
                .BulletPoint("Only works with async/await in .NET 4.5.1")
                .BulletPoint("Limited usefulness in cloud scenarios")
                .BulletPoint("Upgrades a local transaction to a distributed transaction")
                .BulletPoint("Ease of coding - If you prefer implicit over explicit")












                .Sample(() =>
                {
                    Assert.Null(Transaction.Current);

                    using (var tx = new TransactionScope())
                    {
                        Assert.NotNull(Transaction.Current);

                        SomeMethodInTheCallStack();

                        tx.Complete();
                    }

                    Assert.Null(Transaction.Current);
                });
        }
예제 #2
0
 public async Task WhatDidWeJustLearn()
 {
     var slide = new Slide(title: "What did we just learn?");
     await slide
         .BulletPoint("Async void is evil! Use carefully.")
         .BulletPoint("Async all the way.")
         .BulletPoint("In a cloud first and async world try to avoid TransactionScope")
         .BulletPoint("Modern frameworks like EF6 (and higher) support own transactions")
         .BulletPoint("Use AsyncPump if you need TxScope and enlist your own stuff.")
         .BulletPoint("Write an async enabled library? ConfigureAwait(false) is your friend");
 }
예제 #3
0
 public async Task Links()
 {
     var slide = new Slide(title: "Useful links");
     await slide
         .BulletPoint("Sample Code including Transcript of what I explained" +
                      "https://github.com/danielmarbach/AsyncTransactions")
         .BulletPoint("Six Essential Tips for Async - " +
                      "http://channel9.msdn.com/Series/Three-Essential-Tips-for-Async")
         .BulletPoint("Best Practices in Asynchronous Programming" +
                      "https://msdn.microsoft.com/en-us/magazine/jj991977.aspx")
         .BulletPoint("Participating in TransactionScopes and Async/Await" +
                      "http://www.planetgeek.ch/2014/12/07/participating-in-transactionscopes-and-asyncawait-introduction/")
         .BulletPoint("Working with Transactions (EF6 Onwards)" +
                      "https://msdn.microsoft.com/en-us/data/dn456843.aspx")
         .BulletPoint("Enlisting Resources as Participants in a Transaction" +
                      "https://msdn.microsoft.com/en-us/library/ms172153.aspx");
 }
예제 #4
0
        public async Task StoreAsync(DatabaseMode mode)
        {
            var slide = new Slide(title: "Store Async");
            await slide
                .BulletPoint("OMG! You just rolled your own NoSQL database, right?")

                .Sample(async () =>
                {
                    var database = new Database("StoreAsync.received.txt", mode);
                    StoringTenSwissGuysInTheDatabase(database);

                    try
                    {
                        await database.SaveAsync().ConfigureAwait(false);
                    }
                    finally
                    {
                        database.Close();
                    }
                });
        }