Ayende @ Rahien

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

ayende@ayende.com

+972 52-548-6969

, @ Q c

Posts: 5,953 | Comments: 44,406

filter by tags archive

Book Reivew: Sanctuary


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


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


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;
  while(RunThread)
  {
   cmd = (ICommand)queue.Dequeue();
   if (logger.IsDebugEnabled) logger.Debug("Running command: "+cmd.Name+". Command Info: "+cmd.Info);
   cmd.Execute();
  }
 }
 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


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
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
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
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
REM
@echo Succeeded.
@echo
@echo NOTE: When the Windows file protection message pops up,
@echo click Cancel, then click Yes to confirm your intentions.

FUTURE POSTS

No future posts left, oh my!

RECENT SERIES

  1. The RavenDB Comic Strip (3):
    28 May 2015 - Part III – High availability & sleeping soundly
  2. Special Offer (2):
    27 May 2015 - 29% discount for all our products
  3. RavenDB Sharding (3):
    22 May 2015 - Adding a new shard to an existing cluster, splitting the shard
  4. Challenge (45):
    28 Apr 2015 - What is the meaning of this change?
  5. Interview question (2):
    30 Mar 2015 - fix the index
View all series

Syndication

Main feed Feed Stats
Comments feed   Comments Feed Stats