DCSIMG
C# 5.0 - Pavel's Blog
Sign in | Join | Help

Pavel's Blog

Pavel is a software guy that is interested in almost everything
software related... way too much for too little time

Browse by Tags

Windows Phone 8 Dev Camp
22 April 13 03:13 PM | pavely | with no comments
A few hours ago, Ariel Ben Horesh and myself presented two sessions for Windows Phone 8 development at Microsoft offices in Ra’anana (Israel). Thank you all for attending! It was fun – it was the second time I presented with someone else (Ariel) at the same time… we had no time to rehearse, but it was great! The code we showed can be found on github at https://github.com/arielbh/RightMyGuide . The slides links are below. Enjoy! BTW, the IMDB service I created to run on Azure will not be up forever...
Task and TaskCompletionSource
12 April 13 10:38 AM | pavely | 1 comment(s)
The Task and Task<T> classes have been around since in .NET 4, and are fairly well known. In .NET 4, the typical usage of a Task is to run some code on a separate thread (by default using the thread pool), as a better alternative to the raw thread pool. Task has a multitude of constructors, but all of them expect a delegate that is the code to be run when the task is executed. Task provides methods such as Wait , so that code can continue when a Task finishes, and powerful continuation model...
C# Extension Methods and Fluent Interfaces
07 February 13 03:42 AM | pavely | 1 comment(s)
The idea of fluent interfaces is not new, and has many forms. The basic idea is to use a single statement to encompass a series of operations that are natural, or at least simple, to use. There are very few fluent interfaces in .NET – the most well known, which has some fluent interface semantics, is the System.Text.StringBuilder class. Here’s a simple example: public static string BuildInfo(Process process) { return new StringBuilder( "Process " ) .AppendLine(process.ProcessName) .Append...
תגים:, , , , , ,
C# 5.0: await and Reentrancy
28 January 13 04:45 AM | pavely | with no comments
The relatively new async/await keywords in C# 5.0 are truly great. I’ve been using them for a while now, and I always contrast these to the way things can be done in C++11 ; and even with the help of PPL tasks – it stands out as clearly victorious, with its ease of use and lack of verbosity. In fact, it’s so easy to use that I find myself creating new methods that are mostly “Async”, even if the benefit may not be that great – just because it’s easy to do. For example, suppose there is a method that...
Making HTTP calls in WinRT with C++
14 January 13 04:36 AM | pavely | with no comments
When working with Windows Store applications (“metro”), it’s sometimes necessary to make HTTP calls. one classic example is to register for push notifications . After obtaining a unique channel URI, the app needs to send that URI to its application server, as that particular URI is the one to use by the application server to execute a push notification against the Windows Notification Service (WNS). Getting the channel URI is fairly simple, with a call to the static PushNotificationChannelManager...
Windows Phone 8: Integrating with the Wallet
08 November 12 11:18 AM | pavely | with no comments
Earlier this week, Microsoft held the Discovery event in Tel Aviv, Israel, with a distinguished guest, Steve Ballmer. In the event, Microsoft has officially launched Windows 8 and Windows Phone 8 (and XBOX 360 and Kinect…) in Israel. During the presentations, a wallet application on Windows Phone was shown, which was developed by us, CodeValue (and specifically by me ). This article and this one describe something about the app (in Hebrew). Here are some screenshots (some text is in Hebrew): In this...
Windows 8 & Phone 8 UG August Meeting
29 August 12 11:22 PM | pavely | with no comments
Last evening we had a User Group meeting in Microsoft Offices in Ra’anana, with a lot of activity and fun. Thank you all for participating! In the first part, we discussed the Windows 8 Store from various angles, end user and developer. In the second part, we discussed Windows Phone 7.x and the upcoming 8, along with other sporadic topics - C++, WinRT, DirectX, COM, XNA, XAML… it was fun! And don’t forget the giveaways! Just as a gentle reminder, out next meeting is on September 13th , where we’ll...
Windows 8 Metro: C++/CX vs. C#
25 June 12 10:05 PM | pavely | 9 comment(s)
Lately, I’ve been doing development of a Windows 8 Metro application using C++ only (yes, that’s right, no C#) for a client. The reasons for that are mainly an existing C++ code base and a good C++ acquaintance that the team in question has. I’ve been using the new C++/CX extensions that make it easier to work with the Windows Runtime (WinRT); easier with respect to the Windows Runtime Library (WRL) that uses standard C++ with a bunch of helpers (such as ComPtr<T> as a smart pointer for a COM...
My Visual Studio 2012 & C# 5.0 Presentation
18 June 12 02:02 PM | pavely | 1 comment(s)
This morning I presented a session on new features in Visual Studio 2012 and the new language features in C# 5.0. Thank you all for attending! The presentation and demos can be downloaded from https://skydrive.live.com/?cid=45C1880107EBE12C&id=45C1880107EBE12C%2118700
Visual Studio 2012 and C# 5.0: Upcoming session
02 June 12 03:47 PM | pavely | with no comments
I’m going to give a session at Microsoft offices in Ra’anana (Israel), on the 18th of this month, showing new features in Visual Studio 2012 (RC released a few days ago) and the new features of C# 5.0 (there are two. If you think about async/await – that’s one). The event is free, but you should register at https://msevents.microsoft.com/CUI/EventDetail.aspx?EventID=1032514296&Culture=he-IL See you there!
WPF 4.5 Cookbook
26 April 12 07:40 PM | pavely | with no comments
A few months back, I was approached by Packt publishing , asking me to write a WPF book, in their “cookbook” style, and I accepted. I haven’t written an entire book before, but I have written dozen of courses for Hi-Tech College, John Bryce Training and now for CodeValue , in a range of topics, from Windows Internals and device driver development, to advanced C++, to basic and advanced .NET topics, to WPF, and even some oddities such as the Windows Media Foundation . Writing a book, however, is different...
My Async Programming with C# 5.0 & .NET 4.5 session is available for viewing
28 March 12 10:26 PM | pavely | with no comments
The session I gave at Microsoft Ra’anana two days is available on channel 9 . This was in Hebrew, so if this is not your native tongue, you can probably still enjoy the code demos. Here are the links: Part 1 Part 2 Enjoy!
Asynchronous Programming with C# 5.0 & .NET 4.5 Session
26 March 12 01:38 PM | pavely | 1 comment(s)
This morning I gave a session on asynchronous programming with C# 5.0 at Microsoft offices in Ra’anana. Thank you all for attending, it was great fun! As promised, the presentation slides and demos are attached below (the Windows 8 demos can naturally be run on Windows 8 only). The session was recorded, so if you missed it, or just want to hear the same jokes again, the recording will be available in a few days – check out the MSDN blog for details of availability. Async Demos Async Metro Demo Presentation...
INotifyPropertyChanged implementation with C# 5.0
20 March 12 10:40 PM | pavely | 6 comment(s)
The INotifyPropertyChanged interface has become a very popular interface, typically used in MVVM scenarios (WPF/Silverlight). It looks simple, with a single member, which is an event, and its basic implementation by some data type may be something like this: class Book : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; protected virtual void OnPropertyChanged( string propName) { var pc = PropertyChanged; if (pc != null ) pc( this , new PropertyChangedEventArgs (propName...
What happened to asynchrony with WebClient in .NET 4.5?
17 March 12 04:01 PM | pavely | 1 comment(s)
In the Visual Studio 2010 Async CTP , a bunch of extension methods have been added to the WebClient class, to facilitate the “awaiting” of C# 5.0, such as DownloadStringTaskAsync , which can be simply used like so: var wc = new WebClient (); string result = await wc.DownloadStringTaskAsync( "http://msdn.microsoft.com" ); One of the overloads present in the CTP accepts a CancellationToken , so that the operation could be cancelled by an external CancellationTokenSource . For example: async...
More Posts Next page »