Home » Posts tagged '.NET'

Tag Archives: .NET

Simple Continiuos Integration with FAKE and windows scheduler #fsharp

Below are the details about a very simple CI setup,  the one that simply checks GitHub for changes to ‘master’ and if

there were any, runs FAKE build script.

First FAKE script:

The only part that should be interesting (the rest is standard FAKE) is conditional dependency for ‘Default’ task.

It depends on returned value from a custom FAKE task that checks if there are changes on GitHub.

Here is the custom task:

That is all – “simple” is the keyword  :) – here is the screenshot of it running:


Till next time…

Windows 8: intriguing, brave, risky – and the only sane strategy?

1) Cross-platform app compatibility
	develop once, run on any windows 8+ device?
2) Unified UI design style 
	same Metro style on any windows 8+ device?
3) Unified new runtime that supports any language / markup combo
	based on Chakra? 

@mikehadlow, @CraigCav: Using the #TPL with ASP.NET MVC for scalable web applications – not working?

Mike Hadlow posted about the out of the box ASP.NET MVC support (AsyncControllers) for developing scalable web tiers. He gives reasons why the “old” APM style of writing AsyncControllers is cumbersome and then shows how can we utilize TPL library to make code more maintanable and laments that MVC still doesn’t have full/deep support for TPL Library… Craig Cavalier takes it from there and, with the help of ASP.NET MVC Futures and TPL Extensions Library shows how that works end to end. Very nice… I had to try it. Got a test  mvc site with simple example that uses “old” style AsyncController approach and that shows which part is executing from which thread. This is the result:

Seems, fine. We get to not block on the ThreadPool thread – as designed for. Code is old APM style, and this is how the code for this controller  looks like:

using System;
using System.Threading;
using System.Threading.Tasks;
using System.Web.Mvc;

namespace MvcApplication3.Controllers {
	public class HomeController : AsyncController {
		public void IndexAsync() {
			ViewData["indexAsync"] = Helper.GetThreadInfo("IndexAsync");
			Task.Factory.StartNew(LongOperation, TaskCreationOptions.LongRunning) ;

		public ActionResult IndexCompleted(string reault) {
			ViewData["longOperation"] = AsyncManager.Parameters["result"];
			ViewData["indexCompleted"] = Helper.GetThreadInfo("IndexCompleted");
			return View();

		void LongOperation() {
			try {
				AsyncManager.Parameters["result"] = Helper.GetThreadInfo("LongOperation");
			finally {

Then I tried to do the same for Craig’s example… and that doesn’t look good, we are now just grabbing additional thread from the thread pool, while blocking on the original thread. The very reason why AsyncController was there in the first place, seems to be negated.

Here are the results (tried many times with the same results):

Here is the code for this case:

using System.Linq;
using System.Threading.Tasks;
using System.Web.Mvc;
using AsyncControllerHelper;
using Suteki.AsyncMvcTpl.Services;

namespace Suteki.AsyncMvcTpl.Controllers {
	public class HomeController : Controller {
		readonly UserService userService = new UserService();

		public HomeController() {
			IControllerDescriptorCache descriptorCache = new AsyncControllerDescriptorCache();
			ActionInvoker = new BetterAsyncControllerActionInvoker(descriptorCache);

		public Task<ViewResult> Index() {
			ViewData["indexAsyncPre"] = Helper.GetThreadInfo("IndexPre");

			var _view = from user in userService.GetCurrentUser()
									select View(user);

			ViewData["indexAsyncPost"] = Helper.GetThreadInfo("IndexPost");

			return _view;

		public Task DoStuff() {
			var doStuff = from user in userService.GetCurrentUser()
										from _ in userService.SendUserAMessage(user, "Hi From the MVC TPL experiment2")
										select View("index", user);
			return doStuff.ContinueWith(x => { });

I may be doing something wrong. Will check later – it is Sunday afternoon after all…

From mike’s post:
“… You should only ever use this technique if you have an immediate scalability concern and you know that it is caused by a threadpool full of threads blocked by long running IO operations.”

Mike’s original post.

Object and Collection Initializers #csharp

I would like to have a way to declare auto property setters as private, but still be able to use them in object initializers.

Something like this:

class Dog {
    public int Age { get; private set; }
    public string Name { get; private set; }

and then be able to do this:

Dog dog = new Cat { Age = 7, Name = "Mobby" };

but not this:

dog.Age = 11;
Seems not possible... 'internal' doesn't do the right thing too.
So, if I want to use object initializers, I'm forced to open setters for public use, which is not my prefered default approach.
Did I just fall asleep during that class?
Object and Collection Initializers (C# Programming Guide).

#FileDB – A C# database to store files

used something similar (in my c++ life) long, long time ago.


#NBuilder – Rapid generation of test objects for .NET

“Through a fluent, extensible interface, NBuilder allows you to rapidly create test data, automatically assigning values to properties and public fields that are of type of the built in .NET data types (e.g. ints and strings). NBuilder allows you to override for properties you are interested in using lambda expressions.”

via NBuilder – Rapid generation of test objects for .NET.


Get every new post delivered to your Inbox.

Join 266 other followers