Cancellation with .NET 4 (Part 2)
Part 1 of this series introduced the async patterns and introduced cancellation with the BackgroundWorker class as it existed since .NET 2. This part shows how the new .NET 4 cancellation framework can be used. Previously to .NET 4, cancellation with async method calls was implemented in different ways if it was supported at all. For example, the BackgroundWorker implements cooperative cancellation by invoking the CancelAsync method, the long-running method needs to verify if it should be canceled by checking the CancellationPending property and needs to cancel by setting the Cancel property of the DoWorkEventArgs. More about this in the...

Cancellation with .NET 4 (Part 1)
For calling methods asynchronously, since .NET 1.0 the async pattern can be used. .NET 2.0 added the event-based async pattern (also known as async component pattern) that makes async calls easier with Windows applications. Before .NET 4 no standard mechanism has been available to cancel asynchronous method calls. That’s new with .NET 4.0. In this blog series you can read about these async patterns as well as the new unified model for cancellation. Async Pattern Calling methods asynchronously several classes from the .NET framework implement the async pattern. This pattern is available with file I/O, stream I/O, socket I/O, WCF...

Resource Management in Interop Scenarios
In a previous blog post I’ve shown a scenario for interop between MFC/C++ and WPF. This blog post didn’t further mention the requirements to release the resources. Naveen also mentioned this in a comment. This information is added here. With the sample code a UserControl1 and a HwndSource object are instantiated. HWND CMFCDialogAppDlg::GetUserControl1Hwnd(HWND parent, int x, int y, int width, int height) { HwndSourceParameters^ sourceParams = gcnew HwndSourceParameters("MFCWPFApp"); sourceParams->PositionX = x; sourceParams->PositionY = y; sourceParams->Height = height; sourceParams->Width = width; sourceParams->ParentWindow = IntPtr(parent); sourceParams->WindowStyle = WS_VISIBLE | WS_CHILD; m_hwndSource = gcnew HwndSource(*sourceParams); m_wpfUC = gcnew UserControl1(); m_hwndSource->RootVisual = m_wpfUC; return...

MFC and WPF Interop
Nowadays still many MFC applications exist. And maybe there’s no reason to rewrite the application as MFC gets big improvements with Visual Studio 2010. With that in mind it would be great to integrate WPF controls within MFC. Of course that’s possible! Interoperability between MFC and WPF is based on two major features: Managed and native code interop Window handles to WPF elements Using managed and native code in a mixed way can be done with C++/CLI. C++/CLI allows using managed code from native classes and the other way around. Instead of extending the C++ language with keywords starting with...

Developer Day 2010
Am 27. April gibt es zum vierten mal den Developer Day in Wien. Diesmal steht dieser Tag im Zeichen von Visual Studio 2010 und .NET 4. Es gibt neue Informationen zu Änderungen bei .NET 4, zeigt einen Application Lifecycle mit Visual Studio 2010, Neuerungen bei C# 4, Informationen zu Threading, der Task Parallel Library, Parallel LINQ wie auch Coordination data structures… Neuigkeiten gibt es auch zu ASP.NET AJAX und JQuery. Natürlich fehlt auch nicht Silverlight 4 und Windows Azure bei den Themen. Ein besoneres Hightlight ist auch das Windows Phone 7! Ich hoffe möglichst viele dort zu sehen! Informationen zu...

Visual Studio 2010 Launch
Visual Studio 2010 and .NET 4 is released! Download it from MSDN! I’m already running it on my systems. The Visual Studio release candidate was faster than the Beta 2 version, the release is faster once more! What’s new with .NET 4 and Visual Studio 2010, why should you switch? .NET 4 has not big-bang new features like we’ve seen with .NET 3 (WPF, WCF, WF), and .NET 3.5 (LINQ), but stabilizing and enhancements in many different areas. New controls and enhancements with WPF, easier configuration with WCF, a complete new WF runtime and library… A major focus on the...

Enumerating Files and Directories with .NET 4.0
With .NET 4 the Directory and DirectoryInfo classes have been extended to allow for enumerated access to filenames and directories. EnumerateFiles, EnumerateDirectories, and EnumerateFileSystemEntries are the new methods to enumerate files, directories, and both files and directories. Instead of retrieving all file system entries before they can be used, with the new methods an enumerator is offered to access the file system and retrieve the filenames during the loop of a foreach statement. This is cool for not having to wait until all the filenames are retrieved. The older methods GetFiles, GetDirectories, and GetFileSystemEntries returned a string[] and thus the...

EU against Silverlight?
After the browser war from the European Union against Microsoft seems to be solved by Microsoft offering a browser ballot from Windows Update, it seems a new case against Microsoft might be opened. Some vendors demand the EU should open a new case against Microsoft as they fear Silverlight gains a big market share. They demand the EU to restrict Silverlight options. www.riastats.com shows a day-by-day increase of the Silverlight market share. The current statistics are that 55.01% browsers worldwide have Silverlight installed. This value is still lower compared to Sun Java (73.01%) and Adobe Flash (96.99%). However, Microsoft is...

Microsoft must guarantee safety of browsers offered by Windows Update
Now as Microsoft offers a browser ballot to allow easily installing different browsers (Safari, Firefox, Google Chrome, Opera, IE, and seven more) Microsoft could get into different issues because of this. This ballot was an agreement with the EU because users were not able to install the browser of choice on their system. Microsoft’s initial plan to offer Windows without any browsers was rejected by the EU because most users would not be able to install any browser on their system in that case. This ballot is in place since 1 month. Now Microsoft could be charged a fine by...

Better Together C# and Visual Basic
C# 3 had new language extensions that are practical for every kind of application. No matter what application you’re creating, property initializers, collection initializers, Lambda expressions, LINQ… can increase productivity no matter if a Windows- or Web-application, a library, service… is created. That’s different with C# 4. The new language extensions are extremely useful for integrating with dynamic languages, .NET reflection, COM interop… Not every program created should use the dynamic keyword! Looking at the extensions of Visual Basic 2010 it becomes very clear that a goal with C# and Visual Basic is that one language gets the features of...