Color Gradient Generator

Tuesday, November 12, 2013

A while back, I created a WPF Mandelbrot Set program with zoom abilities. I demonstrated the use of async/await for writing code that works asynchronously (to keep the UI responsive), but is easy to write as synchronous code. Here’s a sample image:The image is grayscale, so I wanted to make it use colors, to indicate the level of “being part of” the Mandelbrot set. The problem here is how to create a nice color gradient that moves smoothly from color to color.One possible option might be to leverage an existing class, such as WPF’s LinearGradientBrush, set up a bunch...

WDCIL Presentation and Demos

Tuesday, June 18, 2013

This evening I gave a talk on the Task Parallel Library (TPL) and the asynchronous programming features of C# 5.0 & .NET 4.5 at the Israeli Web developers user group. Thank you all for coming, I had a lot of fun!Although the TPL has been around in release for for more than 3 years, I’m still surprised to find developers who know little about and don’t use it. This is unfortunate, as I consider the TPL one of the best parts of .NET. I wish more developers learn it and use it. The same goes for C# 5.0. For...

XAML as DSL

Sunday, May 5, 2013

About 3 years ago, when .NET 4 and Visual Studio 2010 were just released, I’ve blogged (part 1, part 2) about the changes that took XAML from its WPF inception to the System.Xaml namespace and System.Xaml.Dll assembly, to be available more generally, not just for WPF. I’ve shown that XAML is just a declarative way of creating objects, setting their properties – sometimes in interesting ways. I did promise at the end of that second post that I’d show how to use attached properties, but never did have the time to deliver. 3 years later, it’s high time I...
one comment

C# 5.0: await and Reentrancy

Monday, January 28, 2013

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 does some...

Making HTTP calls in WinRT with C++

Monday, January 14, 2013

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::CreatePushNotificationChannelForApplicationAsync method. Now comes the tricky part: how to send the resulting URI to the application server?In .NET, things are relatively easy. Just use...

Preview of Blend 5 available

Tuesday, December 25, 2012

When Visual Studio 2012 came out, one thing was sorely missing. An Expression Blend tool that can handle WPF 4.5 applications. Blend for Visual Studio that is currently available only supports Windows 8 Store Apps, but not WPF (or Silverlight).A few days ago, Microsoft released a preview of Blend 5 (with Sketchflow), that’s able to work with WPF and Silverlight, along with Windows 8 Store apps.The tool can be downloaded from here: http://www.microsoft.com/en-us/download/details.aspx?id=30702Microsoft stated that the final version of the tool will be available with Update 2 of Visual Studio 2012 (Update 1 was released about 2 weeks ago).
no comments

Windows Phone 8: Integrating with the Wallet

Thursday, November 8, 2012

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 post, I’d like to show the basic steps to integrate an application with the built-in Windows Phone...
no comments

Windows 8 Store Apps: Class Library vs. Windows Runtime Component

Tuesday, October 30, 2012

When working with Windows 8 Store apps in C# (or VB, but I’ll stick with C#), there are several ways of creating reusable (or at least seemingly reusable) class libraries for Windows 8 Store projects. In this post, I’ll take a to look at the options, contrasting their features and usefulness.Looking at the new project dialog in Visual Studio 2012, under the Windows Store node (under Visual C#), we can see the following:There is a third option, the traditional Class Library project located under Visual C# / Windows. Where does that fit in?A Windows Runtime Component project is a...
no comments

WPF 4.5: Accessing bound collections on non UI threads

Saturday, July 21, 2012

The single threaded behavior of WPF (and other UI technologies) requires that anything tied to the user interface be manipulated on the UI thread, incuding data bound objects. There are several ways to do that, assuming the code is on a non-UI thread, such as using Dispatcher.(Begin)Invoke, capturing and using the current SynchronizationContext, etc.Specifically, if some collection is data bound, items cannot be added or removed from it from a non-UI thread. WPF 4 (and earlier) throws an exception, because the data binding mechanism expects to be notified of changes (e.g. ObservableCollection<T>) on the UI thread.One of the improvements...
no comments

Windows 8 Metro: C++/CX vs. C#

Monday, June 25, 2012

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/WinRT interface).Even with C++/CX, the amount (verbosity) and complexity of of...