Ayende @ Rahien

My name is Oren Eini
Founder of Hibernating Rhinos LTD and RavenDB.
You can reach me by phone or email:


+972 52-548-6969

, @ Q c

Posts: 6,026 | Comments: 44,842

filter by tags archive

Book Reivew: Sanctuary

time to read 1 min | 165 words

Product image for ASIN: 0756402468 Sanctuary by non else but Mercedes Lackey

The first thing to note about this book is that it's short, and it's not as packed with action as I hoped it would. The target audiance are young adults, and for them I think that the book would do very well. I found that I want it to be longer, and with bigger scope.

However, the book is entertaining, and there was more than one point in which I had to point it down to laugh it out*. The book ends much faster than I expected, and the ending was the usual good beating evil, but it was very nicely executed and overall a good read.

* There is a point where the hero says that dragons do not have magical ability to travel through time, a clear reference to Pern.

Databinding snafu

time to read 2 min | 239 words

A few hours ago I thought that I was going crazy, I'd had a form that wouldn't save changes unless I closed it without saving first. I debugged it long and hard, and I couldn't find any reason whatsoever for this. Saving and then closing wouldn't work, but closing and saying yes to the unsaved message would.

The call stack from each was the same, and for the life of me I couldn't find what is wrong. I was ready to get NHibernate's code and start debugging that (I'm pleased to say that so far I didn't get to find any bugs in it :-) ). However, I turned on logging first and realized that NHibernate wasn't issuing an update statement at all. The only case where NHibernate doesn't execute an update statement when you tell it to is when you don't have any updates to your object.

That was the answer, I was using databinding in the form, and the field I was changing wouldn't update the datasource until it lost focus (which is reasonable, I guess), but it cause me no end of grief. When I moved the focus to another control, it worked.

Just goes to say that you really needs to know what you are doing before you do it*.

*This is my first serious attempt of using databinding.

More Multi Threading

time to read 3 min | 571 words

Well, I improved on my multi threading code, but I was still not satisfied about the way it work, it created threads unnececarily, so I decided to improve it. Again, I'm using Udi Dahan's ThreadSafeQueue for multi threading.

The idea is based on what Udi Dahan had to say on the comments for my post, and is actually very simple, the queue host intellegent commands, and the working thread simply has to pull them out of the queue and execute them, one at a time.

Here is the working thread implementation:

public class ThreadedCommandExecutioner
 ILog logger = LogManager.GetLogger(typeof (ThreadedCommandExecutioner));
 private readonly IQueue queue;
 bool runThread;
 public ThreadedCommandExecutioner(IQueue queue)
  this.queue = queue;
  runThread = true;
 public void Run()
  ICommand cmd;
   cmd = (ICommand)queue.Dequeue();
   if (logger.IsDebugEnabled) logger.Debug("Running command: "+cmd.Name+". Command Info: "+cmd.Info);
 public bool RunThread
  get { return runThread;}
  set { runThread = value; }

Now the only thing that I need to do when I want to run a job in the working thread is to add a command to the queue. [Currently I've BuildProjectCommand & ExecuteQueryCommand]

The nice thing about this is that I can expand this to more threads without having to do much beyond spun those threads (or better, just use ThreadPool).

Testing this is a little bit tricky, because I'm not really interested in starting threads in my tests, I managed to get around it by using the  DelegatingConstraintWithArgs I'm not sure that this is a good thing, though. Suggestions?

By the way, I really do need to start using NCover again, I've done an extensive modification, and I didn't get nearly enough breaking tests. (It's all because of the UI, I swear :-)).

Replacing notepad with notepad2 On Windows XP Service Pack 2

time to read 3 min | 403 words

I really like Notepad2, but the post about Replacing notepad with notepad2 wouldn't work on XP SP2, here is one that works, apperantly the only change is from %systemroot%\system32\dllcache to %systemroot%\ServicePackFiles\i386

@echo Replacing NOTEPAD.EXE with notepad2.EXE ...
REM 1. Prevent the protected file system from doing its thing.
attrib -r -h -s %systemroot%\system32\dllcache
del %systemroot%\system32\dllcache\notepad.bak.exe
ren %systemroot%\system32\dllcache\notepad.exe notepad.bak.exe
attrib +r +h +s %systemroot%\system32\dllcache
attrib -r -h -s %systemroot%\ServicePackFiles\i386
del %systemroot%\ServicePackFiles\i386\notepad.bak.exe
ren %systemroot%\ServicePackFiles\i386\notepad.exe notepad.bak.exe
attrib +r +h +s %systemroot%\ServicePackFiles\i386

REM 2. Make backup copies of Notepad in the Windows and System32 folders.
del %systemroot%\system32\notepad.bak.exe
copy %systemroot%\system32\notepad.exe %systemroot%\system32\notepad.bak.exe
copy %systemroot%\notepad.exe %systemroot%\notepad.bak.exe
REM 3. Copy notepad2 to Notepad in  the Windows and System32 folders.
del %systemroot%\notepad.exe
copy notepad2.exe %systemroot%\notepad.exe
copy notepad2.exe %systemroot%\system32\notepad.exe
@echo Succeeded.
@echo NOTE: When the Windows file protection message pops up,
@echo click Cancel, then click Yes to confirm your intentions.


No future posts left, oh my!


  1. Technical observations from my wife (3):
    13 Nov 2015 - Production issues
  2. Production postmortem (13):
    13 Nov 2015 - The case of the “it is slow on that machine (only)”
  3. Speaking (5):
    09 Nov 2015 - Community talk in Kiev, Ukraine–What does it take to be a good developer
  4. Find the bug (5):
    11 Sep 2015 - The concurrent memory buster
  5. Buffer allocation strategies (3):
    09 Sep 2015 - Bad usage patterns
View all series


Main feed Feed Stats
Comments feed   Comments Feed Stats