December 2009 Entries
You can use Application.DoEvents() in a headless library, just add a reference to System.Windows.Forms.
What prompted me to try this is a headless browser implementation I found here.
Of course the first thing I felt compelled to do is replace the Application.DoEvents() by spawning a thread to run the loop poll. That did not work as planned and the mshtml class just stalled.
Not feeling like reinventing the wheel, I added the reference to Forms, put the DoEvents back inline and bingo!
Reflecting DoEvents, it appears that a message pump is being run. Not something I have any desire to touch....
Not going to write a novel. just a snippet. Mayhaps will explain when I am sure I know what I am talking about.
private static void InlineThreadingWithLambda()
{
int local = 0;
var thread = new Thread(() =>
{
...
Conventional strategies for reading both StandardOut and StandardError involve helper methods and state objects similar to Listing 1
Listing 1: How it has been done:
public static void RunProcessConventional(string command, string args)
{
var proc = new Process
{
StartInfo =
...
While trolling the interwebs trying to clear up some lexical ambiguity that clouds my mind at times regarding c# closures, lambdas, actions, predicates, anonymous methods and delegates and ran across a post on Rick's blog with a comment that brought a long forgotten hair-pulling-outty session I had while writing some JavaScript UI code.
Specifically, the not so obvious way that closure scope combined with delegates can creep up and bite you on the ass if you don't pay attention.
public class ClosureScopeStudy
{
public void AccessingAModifiedClosure_OR_WhatNotToDoAndHowToFixIt()
...
I started work on a new Google Maps project and decided it was time to shift to V3 and needed a new VS 2008 intellisense helper file.
5 or 6 hours of UltraEdit regular expression slashing and hacking and here you go.
http://gmapvsdoc.codeplex.com/
UPDATE: 02/25/10 - the api shifted a bit so I rebuilt the file.