Sign in
Being Cellfish
Stuff I wished I've found in some blog (and sometimes did)
Translate This Page
Translate this page
Powered by
Microsoft® Translator
Tags
*nix
.Net
Agile
Azure
BDD
C++
Christmas
DDD
Development
GUI
Java
Kanban
MFC
Military
Open source
Pages
PHP
Python
Relocate
Review
Robot
Ruby
SCX
Security
SQL
TDD
Test
Tools
Browse by Tags
MSDN Blogs
>
Being Cellfish
>
All Tags
>
.net
Tagged Content List
Blog Post:
Collection initializers not doing what you expect
Emil Gustafsson
Let's assume that you have a class that have a collection property and that you want the default for that collection to be to actually have a value. That class might look like this: 1: class Foo 2: { 3: public Foo() 4: { 5: this .Numbers = new List< int > { 4711 }; 6: } 7: public...
on
9 May 2013
Blog Post:
Task-based Asynchronous Pattern - kick starter
Emil Gustafsson
Regardless of if you are new to TAP (Task-based Asynchronous Pattern aka " async/await ") or have been doing it for a while this presentation from an MVP summit in February (2013) serves both as a good introduction explaining how it works as well as providing deeper knowledge and high-lighting a few...
on
2 May 2013
Blog Post:
How to know when the garbage collector is not helping you
Emil Gustafsson
A while back I did an experiment where it turned out that allocating objects was better than pooling them. Since then I have encountered a few times where allocating actually turned out to be a bad thing. I've never seen this being a problem in a client application, but in servers allocating a lot of...
on
25 Apr 2013
Blog Post:
Factory pattern improved
Emil Gustafsson
My impression of most major west coast cities like Seattle, San Francisco, Los Angeles etc, is that people in general are very healthy. And Redmond where Microsoft have its HQ is even the bicycle capital of the north west (I guess anything can be the capital of anything if you just constrain geography...
on
1 Apr 2013
Blog Post:
Implementing a good GetHashCode
Emil Gustafsson
If you've ever implemented GetHashCode you probably did it the way suggested in MSDN which is using XOR. And if you use R# you might have seen that it generates a different GetHashCode using prime numbers. So what should you do? I think there are three properties you want to aim for when it comes to...
on
21 Feb 2013
Blog Post:
Implementing IDisposable
Emil Gustafsson
The IDisposable is probably one of the most abused interfaces in .Net. Except from all the cases where you actually have an unmanaged resource you need to release I've seen it being used a lot of times (including by myself) just to guarantee some code is executed immediatly when a variable go out of...
on
7 Feb 2013
Blog Post:
Task-based Asynchronous Pattern - PauseToken and common problems
Emil Gustafsson
I just wanted to make sure you did not miss this article describing a mechanism to pause asynchronous processing. Just like the article state that this came out of a problem encountered in the UI World I think this is something I would not expect to see a lot outside the UI world. But it could be used...
on
31 Jan 2013
Blog Post:
Reactive Extensions Reminder
Emil Gustafsson
It's been a while since I last looked at Rx and I must confess that my first impression was that the amount of possibilities to do the same thing and all the extension methods was overwhelming at start. But like with any new framework you learn you'll settle for a few to solve your most common problems...
on
24 Jan 2013
Blog Post:
TestInitialize execution order
Emil Gustafsson
This was brought to my attention and I was blown away by the fact that somebody would mark classes as TestClass without any tests in them just to reuse some setup code. And that they then make any assumptions on in which order the methods are called. If you really want to do that the constructor is a...
on
14 Jan 2013
Blog Post:
Task-based Asynchronous Pattern - WaitAsync
Emil Gustafsson
Recently I was asked about a specific scenario when some code was being converted into using TAP and this was code that already used tasks. Since the existing code used the "IsFaulted" property a lot I came up with this little extension method making it easy to see if a task failed or not using the await...
on
7 Jan 2013
Blog Post:
Type casting with extension methods
Emil Gustafsson
Once in a while I need to convert one object from one type to another because they represent slightly different views of the same data but they do not share a common parent. An example would be an object used internally representing some complex state for something (let us call it FooComplex) and someting...
on
17 Dec 2012
Blog Post:
Task-based Asynchronous Pattern - WhenRandom
Emil Gustafsson
I couldn't resist to create a method to deal with a scenario even less common than WhenSome . The crazy scenario here is that you have N tasks of type Task<T> and you want to return when a random task completes. The easiest way to do this is to just pick a random task and wait for it like this...
on
6 Dec 2012
Blog Post:
The tale of an UnobservedTaskException
Emil Gustafsson
Last week I helped a colleague who was experiencing UnobservedTaskExceptions I his code. The problem was essentially that the code started several tasks and then in a loop checked each one if it was faulted or not. If a task was faulted the method threw an exception. This meant that if two tasks faulted...
on
18 Oct 2012
Blog Post:
Task-based Asynchronous Pattern - WithCancellation again!
Emil Gustafsson
Last week Stephen Toub covered WithCancellation in a more thorough way than I did . You should read his article too!
on
8 Oct 2012
Blog Post:
Task-based Asynchronous Pattern - WhenAllOrErrorBatched
Emil Gustafsson
This is a variant of WhenAllorError that a colleague asked me about. His scenario was that he had a lot of tasks to complete but since they all involved making HTTP requests to other servers he did not want to start them all at once but rather start a few and then as they completed start a few more....
on
1 Oct 2012
Blog Post:
Task-based Asynchronous Pattern - WhenSome
Emil Gustafsson
I don't think this is the most common case, but sometimes you have a large number of tasks and you're interested in the result from a few of them, but not all of them. Here are some extension methods to wait for some tasks (no pun intended): 1: public static Task WhenSome( int target, params Task...
on
17 Sep 2012
Blog Post:
Task-based Asynchronous Pattern - WhenAllOrError
Emil Gustafsson
A very common scenario when you scatter and gather, i.e. start a number or parallell tasks and then wait for them all, is that you really just want to wait for all if they all succeed. in the case there is an error you typically want to wait no more, handle the error, cancel any tasks not already completed...
on
13 Sep 2012
Blog Post:
Task-based Asynchronous Pattern - WithCancellation
Emil Gustafsson
if you're working with a Task based API that does not follow the TAP rules and hence does not expose an option to cancel you can always add your own this way: 1: public static Task<T> WithCancellation<T>( 2: this Task<T> task, 3: CancellationToken cancellationToken) 4:...
on
10 Sep 2012
Blog Post:
Task-based Asynchronous Pattern - WithTimeout
Emil Gustafsson
The same way we in CCR sometimes wanted to add a timeout to an existing "task" you probably want to do the same in TAP . So here are two extension methods you could use to add a timeout to any task of your choice: 1: public async static Task WithTimeout( this Task task, TimeSpan timeout) 2: { ...
on
6 Sep 2012
Blog Post:
Task-based Asynchronous Pattern - Introduction
Emil Gustafsson
With .Net 4.5 and async / await we have yet another pattern for asynchronous programming and it's time for you to really embrace this. The pattern is called Task-based Asynchronous Pattern , or TAP for short. in my opinion a good asynchronous pattern makes asynchronous code look synchronous. i think...
on
3 Sep 2012
Blog Post:
Adopt a chaos monkey
Emil Gustafsson
Remember the Netflix Chaos Monkey ? Last week they released the source code for it . maybe we'll see a port to .Net and Azure on codeplex soon?
on
9 Aug 2012
Blog Post:
ShimNotSupportedException when using ReSharper unit test runner
Emil Gustafsson
I recently did some work using the VS 2012 RC together with R# 7 . I needed to use the shim functionality from Fakes but ran into trouble. My unit test failed with a ShimNotSupportedException. After a little bit of searching I realized it was because I was using the R# unit test runner (since it's much...
on
6 Aug 2012
Blog Post:
Working with threads
Emil Gustafsson
I co-worker of mine stumbled over a nice collection of helpful information when working with threads in C# . Once you start using .net 4.5 with its async/await patterns you might be using multi-threading more than before and it's good to understand the basics.
on
26 Jul 2012
Blog Post:
Adding a timout to a task
Emil Gustafsson
Remember how I added a timeout to an existing Choice in CCR ? Well with the new Task based world in .Net 4.5 you will probably want to do the same thing with a task returned by somebody else. Good for me this time is that somebody else already figured out how to do it . I especially like the approach...
on
27 Jun 2012
Blog Post:
Object pooling vs creating lots of them
Emil Gustafsson
If you, like me, have a background in C programming it's a spine reaction to avoid lots of memory allocations. So when you encounter a situation in managed code where you need to allocate lots of objects over time it feels natural to introduce a pool of objects. However I remembered reading somewhere...
on
22 Feb 2012
Page 1 of 3 (59 items)
1
2
3