Dixin is a UI designer and knows a little bit about programming.
What is awaitable
Part 1 shows that any Task is awaitable. Actually there are other awaitable types. Here is an example:
Task<int> task = new Task<int>(() => 0); int result = await task.ConfigureAwait(false); // Returns a ConfiguredTaskAwaitable<TResult>.
The returned ConfiguredTaskAwaitable<TResult> struct is awaitable. And it is not Task at all:
Now the async / await keywords are in C#. Just like the async and ! in F#, this new C# feature provides great convenience. There are many nice documents talking about how to use async / await in specific scenarios, like using async methods in ASP.NET 4.5 and in ASP.NET MVC 4, etc. In this article we will look at the real code working behind the syntax sugar.
According to MSDN:
The async modifier indicates that the method, lambda expression, or anonymous method that it modifies is asynchronous.
Since lambda expression / anonymous method will be compiled to normal method, we will focus on normal async method.
Today my Outlook 2010 crashed while I am writing an email. When I restart I got this error:
‘Microsoft Office Outlook’ exited without properly closing your Outlook data file ‘c:\Users\dixinyan\AppData\Local\Microsoft\Outlook\email@example.com’. ‘Microsoft Office Outlook’ must be restarted. If this error message recurs, contact support for ‘Microsoft Office Outlook’ for assistance.
I got this from the local dealership. These photos were taken at Microsoft Building 35:
LINQ to SQL has a lot of great features like
- strong typing
- query compilation
- deferred execution
- declarative paradigm
etc., which are very productive. Of course, these cannot be free, and one price is the performance.
In the MEF (Managed Extension Framework) for .NET, there are useful ComposablePartCatalog implementations in System.ComponentModel.Composition.dll, like:
While in Silverlight, there is a extra System.ComponentModel.Composition.Hosting.DeploymentCatalog. As a wrapper of AssemblyCatalog, it can load all assemblies in a XAP file in the web server side. Unfortunately, in silverlight there is no DirectoryCatalog to load a folder.
Last night there was a big party in Redmond: Microsoft Spring Festival Celebration. It is organized by Chime (an employee network group in Microsoft), and it is also the biggest Chinese new year celebration in Seattle area. Thousands of people attended the party, including Steve Ballmer. I also brought my Nikon D700 there.
In this year, I was rewarded as an MVP on C# of Year 2010; at the same time, 3 different groups of Microsoft offered me 3 SDE II positions, and I made my choice. Now, with the help of Microsoft, I just relocated from China to Redmond.
I am very happy to receive the Microsoft Most Valuable Professional Kit:
Some times, command text is followed by ellipsis (…) or not:
For years, many developers told me that ellipses mean a new window or dialog will pop up. For example, here:
- Clicking New / Save / Exit will not pop up new window or dialog;
- Clicking Open… / Save As… / Page Setup… / Print… will pop up new window or dialog.
But this is not correct. Take a look at About Notepad.
First time to appear on www.asp.net homepage as headline!
Recently I needed to demonstrate some code with reflection, but I felt it inconvenient and tedious. To simplify the reflection coding, I created a ToDynamic() extension method. The source code can be downloaded from here.
On day 1, Scott and James talked about Web Platform Installer, ASP.NET core runtime, ASP.NET MVC, Entity Framework, Visual Studio 2010, … They were humorous and smart, and everyone was excited!
This post discusses solutions for anti-forgery request scenarios in ASP.NET MVC and AJAX:
- How to enable validation on controller, instead of on each action;
- How to specify non-constant token salt in runtime;
- How to work with the server side validation in AJAX scenarios.
So far LINQ to SQL data CRUD (Creating / Retrieving / Updating / Deleting) has been explained. This post takes a deeper look at the internal implementation of LINQ to SQL query.
Conflicts are very common when concurrently accessing the same data.
Conflicts in concurrent data access
The following code demonstrates the concurrent conflict scenario:
Database data Changing cannot be talked about without transactions.
Implementing TRANSACTION (BEGIN / COMMIT / ROLLBACK)
The previous post has shown that, when invoking SubmitChanges(), the translated SQL (INSERT / UPDATE / DELETE) are always executed within a TRANSACTION.
Internally, DataContext.SubmitChanges() invokes DataContext.SubmitChanges(ConflictMode.FailOnFirstConflict). The latter is implemented like this:
SQL Server Profiler does not monitor transaction events by default.
After installing SQL Server, when creating a new trace, the default template is “Standard”: