Don’t deadlock with async and await

Posted by Filip Ekberg on April 3 2013 3 Comments

Deadlocking is really something you need to avoid and in case you don’t know what a deadlock is here’s a great illustration of a “real life deadlock”:

deadlock

Basically what has happened here is that all the roads are full with cars and all the cars try to cross the road at the same time. Let’s translate this into computer terms; the cars in this case are the threads and the cross-over is the “thing” that handles these threads. In the illustration above all the cars have driven into the cross-over at the same time and they can’t really back up, hence there’s a deadlock and there’s no way to go.

What happens in a computer program when you get a deadlock is that it freezes and there’s no where to go because all paths are occupied or waiting for something to finish. Let’s say that process X waits for process Y and process Y waits for process X and both of these lock up the GUI thread, this means that the application will die. Hence deadlocking is something you want to avoid.

Normally you solve this by introducing locking and semaphores. As discussed in the article linked above (where I got the very nice illustration) a semaphore can be seen as a traffic light which handles how the cross-over is loaded with cars.

A while back I wrote an article called “Avoid shooting yourself in the foot with Tasks and Async”, I suggest that you should always return a Task from your asynchronous methods and you really should. What I am about to tell you below though is what you should avoid when doing this.

When a method is marked as asynchronous and the await-part is reached, the method will “exit” and return the “awaiting Task“, which means it’s not the Task that runs inside the method but in fact a Task that keeps track of the status of the asynchronous operation.

Let’s look at a basic code sample!

Consider that you have the following basic asynchronous method, all it does is that it waits for 2 seconds and then prints something to the debug window:

private async Task RunAsync()
{
    var run = Task.Factory.StartNew(() => {
        Thread.Sleep(2000);
    });

    await run;

    Debug.WriteLine("Execution done!");
}

Once await is reached, what will happen? A Task will be returned, but which one? Not the one named run! A Task that keeps track on the state machine will be returned.

Now what happens if we call this method on the GUI thread and asks to wait for it to finish? Calling Wait freezes the current thread and since we are on the GUI thread this will freeze the GUI thread, but for how long? When is Wait happy enough to proceed? In fact it will wait for the asynchronous task that handles the state machine to give it a signal that it’s now ready.

However that Task can never be marked as done until the entire method has been completed. Which means that it needs to access the GUI thread again, since we’re back on the calling thread (GUI thread in this case) after await!

This means that all we have to do in order to deadlock is this:

RunAsync().Wait();

I hope that makes sense to you and gives you an insight into what really happens when you use async and await. As with everything: use it wisely and know what it is that you’re doing.

I’d love to hear about your deadlocking stories!

Vote on HN

Seeing problems differently

Posted by Filip Ekberg on March 14 2013 3 Comments

C# Smorgasbord ebook bundle including PDF, ePub and Mobi is still available for €4.99!

We always have interesting discussions at work, both philosophical and mostly programming discussions. Sometimes the things people say make you think a while longer.

The other day a co-worker of mine asked me:

If a tree falls in the forest and no-one is there, will anyone here it?

I quickly responded with this:

No, no-one will hear it but it will still make a sound.

Thinking capThe fact that it will make a sound is proven by science but that’s beside the point. It’s a trick question that leads you to say “No” but if you view the problem differently you’ll soon have a pretty good answer.

While my co-worker was stunned and rather mind blown by my fast and quite accurate response, I think that most of us developers think logically about most of our problems and try to see solutions to puzzles much harder than this particular one.

If we look at problems from more than one perspective and think about all different outcomes, we can and most likely will do better solutions.

Mind blown

I felt kind of smart for a moment there, don’t you just love that feeling?

When it comes to software engineering I try to think outside the box as much as possible. For example I reflect over the following:

  • Is there anything I can do to increase the value to the customer in a timely fashion?
  • If we spend X amount of time refactoring this, how much will we have saved in the long run?
  • If the visitors of the website will never use a mobile device, is it a smart move doing a mobile version?
  • Is the problem parallelizable?
  • Can we add asynchronicity to increase the end user experience without messing up the code?
  • This new feature in .NET seems very cool, but will it add value to the product? (Most times, yes!)
  • What can I do to decrease the memory imprint of the algorithm?
  • Can we use any patterns to make the solution more solid and less error prone?

Do you take the time to think outside the box?

Vote on HN

Challenge yourself and be awesome

Posted by Filip Ekberg on March 6 2013 9 Comments

Just about an hour ago I came back from my first ever run where I didn’t stop to walk even once and ran longer than I’ve ever done before. Even if the time nor the distance is important to someone that is an experienced runner, but to me this is a huge deal.

About 3 minutes after I started running my pulse started increasing a lot and I got the feeling that I just wanted to go back home and lay back in the couch having yet another piece of chocolate cake. However I didn’t, I told myself that I’d at least have to beat my last time and my last distance no matter if it was by 2 seconds and 2 meters; I just had to.

This isn’t and will never be a blog about running, but bear with me, there’s value for any software engineer coming soon! About 3 months ago I was asked at work if I wanted to join and run a half marathon, that’s 21 kilometers and I’ve never even ran a fourth of that distance. For some reason though I said yes because I really need to get in shape to feel better, anyone that have a desk job (probably 100% of the readers here) know that it doesn’t really do the body justice just to sit still for the majority if the day.

So I said yes to this half marathon and as I am a very determined person I am going to finish this race, no matter what time or in what condition; I am going to finish this race!

Here’s why: I believe that challenging yourself over and over again will make you challenge yourself out of habit in the end. This might sound weird but think of it in engineering terms instead. If every day that I sat my foot at work, no matter if it’s for developing trivial tasks or not I would challenge myself into writing one better line of code than the day before. Or even better, I would challenge myself into going back to the previous days work and improve what I had then developed.

In the long term challenging yourself will make you question your solutions and you’ll start to think if this way is the best which ultimately will make you do very good solutions from the start; but there’s always room for improvements! It might sound like a cliché but frankly I think too many of you forget to challenge yourselves or rather you forget to ask or take the time to do so. A friend of mine told me that he tries to optimize his coding performance so that he will output high quality code in a shorter time period so that he then have time to go back and refactor pieces of the solution. This is exactly what challenging yourself helps you do: Improve, Improve and Improve!

In the end, don’t we all just want to be awesome at what we do? No matter if it’s software engineering, running, catering or anything else for that matter?

Tomorrow when you get to work challenge yourself into something like the following and tell me how it felt:

  • Refactor a method that you wrote this week that you’re not entirely happy with
  • Find a class, method or property that you feel needs to be explained better and add a comment or rename it completely
  • Dare to make a breaking change for the better of your product
  • Ask your boss for a license to ReSharper, JustCode or any other productivity tooling

Personally if I hadn’t challenged myself into doing things that scares me I would never had stood in front of a group of people talking about programming, I would never have written my book and I would never have started my own company.

You can be awesome if you just put your mind into it, remember that you’re just as awesome as you see yourself.

There’s a chapter in my book called “Creating a challenge out of the trivial tasks”, the ebook is currently available for €4.99!

Vote on HN

Everyone Should Learn Programming

Posted by Filip Ekberg on March 4 2013 3 Comments

Over the years a lot of highly influential people have dropped the phrase “Everyone Should Learn Programming” and recently some very successful people in software companies made a video called “What most schools don’t teach”. While this video is spot on there seem to be a lot of confusion between learning programming and pursuing programming as a profession.

Almost everything today is built on micro-processors and use electricity and basic knowledge about programming will give you an idea of how complex some systems are. Everyone that works professionally with programming knows that the customer never really knows what it is they want and think they can just change their minds in the middle of the project. How many of you have heard the phrase “Can’t you just move X? That shouldn’t be too hard.”? This is born from a lack of understanding of how systems are built. With basic programming knowledge it might be a lot easier to explain complexity in a lot of the custom built solutions that we tackle every day.

Some say math is the foundation of understanding programming but personally without programming I wouldn’t have understood some math that I’ve experienced. With the help of a very basic program I could make the learning of some math fun and exciting, even if it was just a boring console application. From this point of view programming can make learning difficult topics easier.

Everyone Should Learn Programming because they’ll get a much better understanding of the digital world that we live in.

Pursuing programming as a profession is a completely different subject.

Every programming job that I’ve had have been different, some jobs required me to work more than 40 hours per week and some jobs somewhat had a clock that we clocked-in with and only worked 8 hours per day on weekdays. However a lot of programmers don’t leave their work at work and frankly their personalities aren’t programmed that way. I for one love exploring new things, I love writing about technology and doing as much programming as my personal life lets me. Everyone is different though. I know a lot of programmers that don’t want to live like that, they want 40 hour weeks and that is fine; it works very well for them.

In the video “What most schools don’t teach” everyone started programming before they hit 10 years old, which isn’t at all required for you to work professionally with programming. I know talented programmers that started working with programming in their late 20s and when I worked as a teacher for a programming education we had students that were close to 45. It’s never too late. I even read an article a while back about a man around 85 years old that recently learned JavaScript and he loved it!

Everyone Should Not Work With Programming. But that doesn’t mean everyone shouldn’t Learn Programming.

I program because I love it and when I started working with programming the money was crap but I still did it because I loved it.

What most schools don’t teach

Vote on HN

What language features do you miss in C#?

Posted by Filip Ekberg on March 1 2013 21 Comments

35563491Every now and then I hear people shout “I really wish C# would have X and Y, it would make my life so much easier”. This makes me think about what features I’d like to see supported in the language. There are multiple factors to take into consideration when thinking about what should be a language feature and not.

If C# would be completely open source and driven by the community we would probably see a lot of pull-requests for new language features. But I’d imagine that many of these features were implemented by someone that felt like the problem solved some in their opinion generic case. This might not actually be the case though. When adding a new language feature, to any language, you need to take into consideration that a big part of the community should benefit from it.

A good example is how language features for asynchronous programming were added in .NET 4.5. But asynchronous programming was possible before this. “All” it really does is adding a nice state-machine and does all the heavy lifting for us. This is something that developers doing asynchronous programming would have to implement over and over again thus making it a perfect candidate to become a language feature.

Mindscape has an article about what F# features every C# developer should lust after which brings up some interesting language features such as:

  • Pattern matching
  • Immutability
  • Object expressions

What language features do you miss in C# and why? Keep in mind that a language feature should target a broad audience! Maybe you’re happy with what is in the language right now?

C# Smorgasbord ebook limited-time offer now only €4.99!

Vote on HN

C# Smorgasbord ebook limited-time offer now only €4.99!

Posted by Filip Ekberg on February 26 2013 10 Comments

PriceTag_Off

About 7 months ago I self-published C# Smorgasbord which is a C# Programming book focusing on a lot of different and interesting things. I’ve had a couple of giveaways and a couple of sales so far to spread the word even more.

It’s now time for an ebook limited-time offer, when the offer ends is not yet disclosed so if you’re interested in reading this very well spoken off book get it today for only €4.99! If you don’t have PayPal just send me a message and we’ll figure something out.

The offer includes access to PDF, ePub and Mobi!

After the PayPal purchase you’ll receive an e-mail with a download link within a couple of hours.

CSharpSmorgasbordLogo

Want to peek inside? Sample available!

There’s a “Look Inside” available on Amazon!

About the book

Looking at everything from testing strategies to compilation as a service and how to do really advanced things in runtime; you get a great sense of what you as a developer can do. By taking his personal views and his personal experience, Filip digs into each subject with a personal touch and by having real world problems at hand, we can look at how these problems could be tackled.

No matter if you are an experienced .NET developer, or a beginner, you will most certainly find a lot of interesting things in this book. The book covers important patterns and technologies that any developer would benefit from mastering.

Table of Contents

  • Introduction to Parallel Extensions
  • Productivity and Quality with Unit Testing
  • Is upgrading your code a productive step?
  • Creating a challenge out of the trivial tasks
  • Asynchronous programming with async and await
  • Dynamic programming
  • Increase readability with anonymous types and methods
  • Exploring Reflection
  • Creating things at runtime
  • Introducing Roslyn
  • Adapting to Inversion of Control
  • Are you Mocking me?

Enjoy the read and spread the word!

Want a printed copy?

There’s a discount on that one too!

Discount code: N9UV3WDP

Buy now!

Vote on HN

Optimize your delegate usage

Posted by Filip Ekberg on February 15 2013 19 Comments

Kudos to David Fowler for spotting this! We had a chat on JabbR and David pointed out something quite odd about delegates which he had discovered while optimizing some code.

Let’s assume that we have the following code that declares a delegate and a method that uses it:

public delegate void TestDelegate();

public void Bar(TestDelegate test)
{
    test();
}

Now consider that you want to run this method and pass a method for it to execute that corresponds with the delegate. The process of running this will be in a loop that runs for 10 000 iterations.

The method we want to run is called Foo and looks like the following:

public void Foo() { }

Everything is set up, so what is it that we need to optimize when calling this 10 000 times? Well we have two different ways of using the method with a delegate.

Option 1
The first option is that we can use an anonymous method to call this method looking like the following:

for (var i = 0; i < 10000; i++)
{
    Bar(() => Foo());
}

If we compile this and open it up in Reflector to see what is generated, there’s also some other stuff generated behind the scenes but this is the important part:

TestDelegate test = null;
for (int i = 0; i < 0x2710; i++)
{
    if (test == null)
    {
        test = () => this.Foo();
    }
    this.Bar(test);
}

Looks good so far, right? Let’s take a look at Option 2 and compare.

Option 2
The second option that we have is just writing the method name to tell it to use this like you can see here:

for (var i = 0; i < 10000; i++)
{
    Bar(Foo);
}

This one is quite common and I’ve seen it used a lot, but what happens behind the scenes here?

If we open this up in Reflector we can see that the following code was generated:

for (int i = 0; i < 0x2710; i++)
{
    this.Bar(new TestDelegate(this.Foo));
}

UmpOi

This is significantly different from the lambda one! Is your mind blown yet?

Ok let me break it down, it’s quite simple. What happens with option 2 is that it will create 10 000 instances of TestDelegate and thus using a lot more memory. The lambda version was optimized but the “normal” one wasn’t?

Let’s just verify that it actually does use a lot more memory! I’ve set the solution to compile in Release mode with Optimization turned on and I’m using the following code to test it:

public class Program
{
    public delegate void TestDelegate();

    public void Bar(TestDelegate test)
    {
        test();
    }
    public void Foo()
    { }

    public static void Main()
    {
        var program = new Program();
        GC.WaitForFullGCComplete(100000);
        Console.WriteLine("Memory usage before Lambda version:\t{0}", GC.GetTotalMemory(false));

        program.LambdaVersion();
        Console.WriteLine("Memory usage After Lambda version:\t{0}", GC.GetTotalMemory(false));

        GC.WaitForFullGCComplete(100000);
        Console.WriteLine("Memory usage before Normal version:\t{0}", GC.GetTotalMemory(false));

        program.NormalVersion();
        Console.WriteLine("Memory usage After Normal version:\t{0}", GC.GetTotalMemory(false));

    }
    public void LambdaVersion()
    {
        for (var i = 0; i < 10000; i++)
        {
            Bar(() => Foo());
        }
    }

    public void NormalVersion()
    {
        for (var i = 0; i < 10000; i++)
        {
            Bar(Foo);
        }
    }
}

Here’s the result from that operation:

Memory usage before Lambda version:     29460
Memory usage After Lambda version:      37652
Memory usage before Normal version:     37652
Memory usage After Normal version:      357140

Conclusion

If we use delegates “wrong” or don’t think what code is actually generated this can leave us with large memory imprints. Of course you always need to think about the code you write but in some cases you might not really know what the compiler ends up doing.

By using the lambda version instead in this case we’ve avoided to create a lot of new delegate instances and thus minimized the memory imprint.

Fun fact: If we compile the “normal version” using MonoDevelop and Mono (2.10.9) it results in the same output. Which leads me to think that this is by design. The only difference is when we compile the lambda version but nothing significant that changes the behavior at all.

Do you say this is a bug or a feature? Did you know it behaved like this?

Vote on HN

Decompiling .NET Applications

Posted by Filip Ekberg on February 14 2013 14 Comments

There are many reasons to why you might want to decompile an application after it’s been compiled. Compiling C# code “just” translates it into MS IL. The compiler of course does some magic and tweaks the code as much as possible. There’s no metadata stored after compilation which means that comments and such will not be available in the IL output.

The following image illustrates what happens when we compile something, we put the C# code into a basket and tell the compiler to give us a binary of this which is sort of a black box at the moment. We know that whenever we want to use this black box we have something behind the curtain that knows how to open it and use it properly (read: CLR).

Compiling C# Code

Let’s consider a basic variable instantiation and an equality check, when this is compiled it will output something partially readable. To me the output is readable but that’s just because I have a weird love for IL. When this basic snippet was compiled using LINQPad it generated some IL which you can see below.

Compiled C# Code

Imagine that you got a DLL from an old co-worker and the code is long gone but you need to make some changes to the code. What do you do? One option is to mimic the functionality if the application is not too big and create it from scratch but that is just cumbersome. Instead what we want to do is something like you can see illustrated below; we want to go back from IL to C#!

Decompiling C# Code

So how do we do this? By using a decompiler!

As I tend to do this quite often to understand how libraries work that I have no control over, I have tried some different tools for just this cause. Let’s take a look at four of the most common ones on the market. Don’t worry, there’s both free versions and paid ones out there!

Telerik JustDecompile

The first one that we’re looking at is a product from the Just* family created by Telerik. I do like the products from Telerik so this one should be quite interesting!

JustDecompile is completely free and available for download over at Teleriks website. One thing that I didn’t like thought was the installer, generally Telerik’s installers are pretty nice, but I don’t like being “guided” to install other stuff than what I’ve asked for.

Below is a screenshot of the installer and as you can see it advices you to install a lot of trials for other Telerik products.

JustDecompile Installer

After selecting only to install JustDecompile the installation will only take up 36MB. You’ll also need to create a Telerik account if you don’t already have one which can also be a hassle, but it’s free so why not!

I’ve setup a project that has the same variable declarations and the equality check from above and then compiled and opened the executable in JustDecompile. The result is quite similar to the original source as you can see in the following image.

Decompiling with JustDecompile

We can also select to show the result as IL instead of C# code!

Decompile with JustDecompile show IL

There are a couple of things that I didn’t find straight forward using JustDecompile.

Pros

  • It’s free!
  • It’s fast!
  • The UI is beautiful
  • It looks easy
  • Does what it should (partially)

Cons

  • There’s a button for creating a project, I expected it to be able to export my binary to a complete VS Solution but it’s grayed out and there’s no tooltip on why that is so.
  • Showing the source as VB instead of C# shows nothing at all, shouldn’t matter if the original code was C# or not.

JustDecompile Summary

Even though there are some cons; would I recommend you using it? Of course! If you haven’t installed it already go ahead and do so! It can only become better if more people support it and give them suggestions. There’s even a suggestion button where you can submit requests.

ILSpy

This one is interesting, ILSpy is an open source assembly browser and decompiler for .NET Applications! This means that if you don’t like what it does or if you have feature suggestions, “you can just” provide the fix yourself! The tool itself is equal to what JustDecompile offers but the installation process is much easier. You simply grab the binaries or source from the ILSpy website and unzip it wherever you want it!

ILSpy

I simply performed the same process as I did with JustDecompile; I started ILSpy and opened up my executable but this is where it gets interesting. The code that it decompiles to looks Exactly like the code that I wrote in Visual Studio as you can see in the following image.

ILSpy Decompile

Decompiling to VB also works right out of the box, this tool has what it takes!

ILSpy Decompile to VB

Now to the more interesting feature; Can we save/export this to a C# Project?

By the looks of it there’s a “Save Code” action in the File menu, selecting the assembly and then pressing ctrl+s or the “Save Code” action actually lets us save a csproj file! If you open up the location in your file explorer you will see that it actually generated a project file and the code file!

ILSpy Save project and Export Code files

I think we’ve looked enough at ILSpy to write up a pros and cons!

Pros

  • Free!
  • Open-Source, do I need to say more?
  • All features seem to work as they should
  • Easy to use interface
  • Fast!

Cons

  • The UI isn’t really that good lookig but it’s functional
  • The application seemed to freeze once but it just took a while to analyze a code file, I had to stretch for this one..

Summary

There really aren’t many bad parts regarding ILSpy, I like it but if I have to complain about something it’s the UI and that it felt like it froze once. I really recommend trying out ILSpy and looking over the code for it, it’s great for educational purposes and I have co-workers that use it all the time and like it a lot.

What are you waiting for, go download!

dotPeek

Just as the two mentioned above dotPeek is available for free, it’s not open source though. dotPeek comes from JetBrains and is available on their website where you can also find a lot of interesting information about how to use it.

Installing this is easy and doesn’t force you or ask you to install anything else than what you really want in this case.

dotPeek

If you are familiar with ReSharper (R#) which is also a product from JetBrains, the keyboard shortcuts will be something of value to you. In fact dotPeek uses the same navigation as you might be used to from using ReSharper!

Let’s have a look at what dotPeek thinks of our executable. When opening up dotPeek you’re meet with a beautiful interface that feels like it’s a part of the Visual Studio family (except for the very colorful icons). Opening up the executable and looking at the code you can see that it didn’t really give us the same result as any of the other decompilers we’ve looked at.

dotPeek looking at the code

So instead of actually displaying what the IL tells us, it analyzes the IL and optimizes the code for us which is really not what we want to do. There’s also no way of swapping between C#, VB.NET, F# or IL. So in this case we are “stuck” with looking at some C# code without knowing what IL it comes from.

What is also a downside to this is that you cannot export the code that you are looking at, which means that this is a pure code browser.

Pros

  • Beautiful UI
  • Fast
  • Code inspection and navigation that you might be used to from ReSharper
  • Supports plugins just like ReSharper

Cons

  • Lack features such as show code in different ways; swapping between VB.NET, F# and IL
  • Doesn’t resemble the actual code that was compiled
  • Doesn’t support exporting code or projects
  • The application itself seem to be very light-weight and lacking configuration possibilities

Summary

While I like JetBrains products in general, this one feels like there’s something missing. Personally when I use a decompiler I want it to be able to show me the output code in different ways and give me options to export it. But if you are looking for an assembly browser that decompiles to C# and just does that, this is perfect. Even better if you are used to ReSharper, you will certainly find the keyboard shortcuts for navigation handy.

.NET Reflector

Last but not least, my personal choice .NET Reflector! I’m not really sure why this is my personal favorite but keep on reading and you might find that it’s because the mixture of good functionality with a common and easy to use UI.

.NET Reflector is available by RedGate but costs money which is maybe why it’s “better” than the alternatives. This wasn’t always the case though once upon a time it was available for free. I was lucky enough to win a free license a while back so I’ve been able to use it quite a lot. You can buy it or grab a free trial over at RedGate’s website.

The installation is easy and doesn’t try to force you to install a lot of other things that you don’t expect. .NET Reflector comes with a Visual Studio extension that will let you use the features in Visual Studio instead of starting a new instance of .NET Reflector.

Just as with JustDecompile and ILSpy I opened up the executable that we looked at before and as expected it shows the same result as ILSpy does!

.NET Reflector

As you can see here the UI is quite minimal and easy to understand. What is interesting here is that it also allows us to view the code as F# code as you can see in the following image.

.NET Reflector F#

If we want to export the code that we have just as we did with ILSpy we can right click the assembly and select “Export source code” this then asks us where to store it and gives us information about the exported files. As you can see in the two following images it exported more files than ILSpy did.

.NET Reflector Export Code

.NET Reflector Export Code Window

And the resulted files look exactly as we expect them to, the code file has the same code as we did in the original source code.

Pros

  • Easy to use
  • Everything is intuitive
  • Everything work as intended
  • Exports more code than alternatives
  • Fast
  • Beautiful UI
  • Cons

  • It costs $368 + tax if you want the VS Extension and this is quite expensive when good alternatives are completely free
  • Summary

    The costs is the only downside that I’ve found during my time using it which means that if .NET Reflector was free tool for Decompiling .NET Applications it would be the number 1 choice. It isn’t free and the cost must be factored in when comparing the value of the product.

    Conclusion

    If I hadn’t won a free license for .NET Reflector I probably would have used JustDecompile or ILSpy as both of them are very good tools for Decompiling .NET Applications!

    We’ve looked at how we can decompile applications and browse the code in different ways when only having the executable available. This also works with libraries in the global assembly cache.

    Looking around in the .NET Framework to see how they’ve done certain implementations can be great for educational purposes but using this at work to understand how someone implements a certain feature can be priceless.

    I hope you’ve found this read interesting and that you’ll be digging deeper with tools for Decompiling .NET Applications. Let me know which one is your favorite or if you’ve used another tool than the four mentioned above!

    Vote on HN

    Compilation as a Service and the next generation plugins

    Posted by Filip Ekberg on February 7 2013 3 Comments

    I’ve written a lot about Compilation as a Service with Roslyn before on this blog and I just had a presentation about it, again. This time I talked about how to use Roslyn in order to create plugins. Actually how to create two different types of plugins; plugins using Roslyn to analyze code and plugins written for applications created in Visual Studio using Roslyn to compile code.

    I’ve also written about Roslyn in my recently published book (which is currently on a discounted price!), be sure to check that out. For your information the book is available in Print, Kindle, PDF, ePub and Mobi; the three last ones here are included in a purchase of the printed copy!

    Watch the below presentation and let me know what kind of ideas you get based on it and also let me know if you like it or not!

    Enjoy these 50 minutes of Compilation as a Service with Roslyn!

    Vote on HN

    Congratulations to the winners of a free C# Smorgasbord copy!

    Posted by Filip Ekberg on February 4 2013 2 Comments

    Before I announce the winners, yes it’s plural because it was way too hard to decide one winner, I want to share some great news with all of you. Yesterday I summarized the amount of people that have my book based on the copies that I’ve sold/given away and this number is now above 500 and steadily increasing towards 600!

    The feeling I got when receiving my first proof copies of the book is indescribable, it was pure awesomeness and this feeling is almost as great. It makes me very happy that so many developers have decided to get a copy of C# Smorgasbord, thank you all very much for that. All the great feedback and the amount of copies out there are the basis to why I want and can have these giveaways!

    Now to the winners, I know that’s why you’re here anyways. As the giveaway was re-published on DZone I’m going to include those comments as well. Thanks everyone that participated and I really hope that if you didn’t get a free copy this time, you’ll enjoy the discounted price found at the end of this post.

    The winners are:

    Sergio with the following comment:

    Checking the content this book has, it would be a good reference to create great architectures using advanced techniques like Reflection or runtime thing creation. It also shows last features of .Net framework so it will have good examples of how to understand them (I honestly can’t understand async :$ and no good Spanish doc, besides that, I have no credit card to buy the book :P ) I read about the book on this Hacker News’s link: http://blog.filipekberg.se/2012/07/21/c-smorgasbord-will-soon-be-available/
    (I said: “I need that book!!”)

    Adam with the following comment:

    I would like a copy of your book because everything i learn from it will go onto my blog hopefully passing knowledge onto many others.

    I feel your book will fill in various gaps in my knowledge, and will hopefully help secure that senior developer position and finally, i mentor the other developers around me and the junior developers, and this book will be an excellent resource, and with titles such as “Creating a challenge out of the trivial tasks” will hopefully help inspire the developers to take pride in even the trivial tasks.

    Henric with the following comment:

    Don’t leave a former Sigma colleague hanging! I’ll give you a blog post reviewing the book (on my massive 2 visitors a day blog) and I will spread the Smorgasboard love to current co-workers. :)

    Stay awesome!

    Daniel with the following comment:

    I would like a copy of your book, because I think this would greatly benefit my student project in which we are creating an application where stuff can be augmented and moved / edited with simple gestures :-) Right now much of the code is hacked together, because no one in the group used C# before (the university teaches java :-| ), what leads to “not-so-good” performance and way too many bugs! :-) I am responsible for the code quality and C# teaching and the book would help me to be more helpful to the other guys.

    Malte with the following comment:

    Finished my CS degree last summer, and got a job as a software developer, primarily C#. I try to improve my programming skills every day, and found this blog and blogpost through the “Interesting Finds” blog series from Jason Haley.

    Hadn’t heard about your book, but after reading about it, it seems very “hands on”. And i would love to read it.
    I find it especially awesome that you self-published the book :)

    Congratulations on winning a free copy of C# Smorgasbord, I hope you enjoy it and help others become better programmers as well!

    Now to those of you that didn’t win a free copy. I’ve setup a discount code that can be used on CreateSpace (this is where the book is printed) and this will give you a 35% discount!

    Use discount code N9UV3WDP to get 35% off here (takes you to CreateSpace)!

    Pssst.. if you don’t want to wait for the printed copy to arrive due to (sometimes) long shipping, you can get the ebook the same day as you purchase the printed copy! Just fill out this form.

    Enjoy the read and spread the discount code to anyone and everyone!

    Vote on HN