<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Monitor a Process Asynchronously &#8211; More DelegateMarshaler Tricks</title>
	<atom:link href="http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/feed/" rel="self" type="application/rss+xml" />
	<link>http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/</link>
	<description>Just another WordPress weblog</description>
	<lastBuildDate>Wed, 13 Jan 2010 16:31:08 -0600</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Bill Tribley</title>
		<link>http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/comment-page-1/#comment-533</link>
		<dc:creator>Bill Tribley</dc:creator>
		<pubDate>Fri, 29 Aug 2008 16:11:40 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/#comment-533</guid>
		<description>public void Invoke(Action action)
gives the error &quot;Using the generic type &#039;System.Action&#039; requires &#039;1&#039; type arguments CS0305

I am really out of my depth here. I will come back to this when I have a bit more breathing room. It is unfortunate that National Instruments is slow to upgrade the dot-net framework used with their projects, I can fully understand any reluctance to help with down-grading working code.</description>
		<content:encoded><![CDATA[<p>public void Invoke(Action action)<br />
gives the error &#8220;Using the generic type &#8216;System.Action&#8217; requires &#8216;1&#8242; type arguments CS0305</p>
<p>I am really out of my depth here. I will come back to this when I have a bit more breathing room. It is unfortunate that National Instruments is slow to upgrade the dot-net framework used with their projects, I can fully understand any reluctance to help with down-grading working code.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Tribley</title>
		<link>http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/comment-page-1/#comment-532</link>
		<dc:creator>Bill Tribley</dc:creator>
		<pubDate>Fri, 29 Aug 2008 15:46:51 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/#comment-532</guid>
		<description>Looks like I need to re-do the threadingutilities for 2.0, cracking open that code now.</description>
		<content:encoded><![CDATA[<p>Looks like I need to re-do the threadingutilities for 2.0, cracking open that code now.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Tribley</title>
		<link>http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/comment-page-1/#comment-531</link>
		<dc:creator>Bill Tribley</dc:creator>
		<pubDate>Fri, 29 Aug 2008 15:45:11 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/#comment-531</guid>
		<description>Hi Matt,
I commented out the linq. Will establish a reference to the DLL. Ran into several other anonymous methods. I assume that this:
ThreadPoolHelper.QueueUserWorkItem(() =&gt;
                {
can also be replaced by 

private void queueUserWorker() { } 

ThreadPoolHelper.QueueUserWorkItem(queueUserWorker);

correct?</description>
		<content:encoded><![CDATA[<p>Hi Matt,<br />
I commented out the linq. Will establish a reference to the DLL. Ran into several other anonymous methods. I assume that this:<br />
ThreadPoolHelper.QueueUserWorkItem(() =&gt;<br />
                {<br />
can also be replaced by </p>
<p>private void queueUserWorker() { } </p>
<p>ThreadPoolHelper.QueueUserWorkItem(queueUserWorker);</p>
<p>correct?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matt</title>
		<link>http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/comment-page-1/#comment-529</link>
		<dc:creator>matt</dc:creator>
		<pubDate>Fri, 29 Aug 2008 15:11:40 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/#comment-529</guid>
		<description>Hey Bill,

You can probably get rid of the System.Linq using statement since that is part of .NET 3.0.  I don&#039;t think I&#039;m using any Linq in that project.  ThreadingUtilities is the other DLL project in the download that provides the typesafe wrappers to ThreadPool.QueueUserWorkItem (as ThreadPoolHelper.QueueUserWorkItem).  I have a couple posts around here on the blog explaining how that works.

Good luck! :)</description>
		<content:encoded><![CDATA[<p>Hey Bill,</p>
<p>You can probably get rid of the System.Linq using statement since that is part of .NET 3.0.  I don&#8217;t think I&#8217;m using any Linq in that project.  ThreadingUtilities is the other DLL project in the download that provides the typesafe wrappers to ThreadPool.QueueUserWorkItem (as ThreadPoolHelper.QueueUserWorkItem).  I have a couple posts around here on the blog explaining how that works.</p>
<p>Good luck! <img src='http://thevalerios.net/matt/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Tribley</title>
		<link>http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/comment-page-1/#comment-528</link>
		<dc:creator>Bill Tribley</dc:creator>
		<pubDate>Fri, 29 Aug 2008 15:07:10 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/#comment-528</guid>
		<description>Hey, Matt,
Thanks for the quick response and the helpful description.

I have started a project and got stuck on some dot-net framework things, as well as a dependency.

I can&#039;t find System.Linq, I think this is a &gt; 2.0 thing.
What is this:
using ThreadingUtilities;

Many thanks for the help!</description>
		<content:encoded><![CDATA[<p>Hey, Matt,<br />
Thanks for the quick response and the helpful description.</p>
<p>I have started a project and got stuck on some dot-net framework things, as well as a dependency.</p>
<p>I can&#8217;t find System.Linq, I think this is a &gt; 2.0 thing.<br />
What is this:<br />
using ThreadingUtilities;</p>
<p>Many thanks for the help!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matt</title>
		<link>http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/comment-page-1/#comment-525</link>
		<dc:creator>matt</dc:creator>
		<pubDate>Fri, 29 Aug 2008 14:41:58 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/#comment-525</guid>
		<description>Hey Bill,

Glad you like it :)

That block of code is using a lot of the syntactic sugar that C# 3.0 lets you do.  Anything of the form (parm1,parm2...) =&gt; {...; return ___;} is an anonymous method.  It&#039;s just a method that takes two parameters and returns something (or not).  The compiler can infer the type of the arguments and the return value.

In that example, I could have defined a method &quot;private void OnOutputDataReceived(object sender, EventArgs args)&quot; and then done &quot;p.OutputDataReceived += OnOutputDataReceived;&quot;.  This is still shorthand -- the verbose way of saying this is to do &quot;p.OutputDataReceived += new OutputDataReceivedEventHandler(OnOutputDataReceived);&quot;

They&#039;re all equivalent in terms of the compiled code, but hooking up anonymous methods directly to the events can come in handy.

You&#039;ll probably need the ErrorDataReceived event: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.errordatareceived.aspx
You could also just hook into this event and add the text to the same text box if you wanted.  (i.e. put but stderr and stdout into the same box).

As for piping text into the input stream, I think you can hook up a StreamWriter to the StandardInput stream: http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput.aspx

Hope that helps!  I&#039;d be really interested in seeing your final demo showing how to read/write to all 3 streams :)</description>
		<content:encoded><![CDATA[<p>Hey Bill,</p>
<p>Glad you like it <img src='http://thevalerios.net/matt/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>That block of code is using a lot of the syntactic sugar that C# 3.0 lets you do.  Anything of the form (parm1,parm2&#8230;) => {&#8230;; return ___;} is an anonymous method.  It&#8217;s just a method that takes two parameters and returns something (or not).  The compiler can infer the type of the arguments and the return value.</p>
<p>In that example, I could have defined a method &#8220;private void OnOutputDataReceived(object sender, EventArgs args)&#8221; and then done &#8220;p.OutputDataReceived += OnOutputDataReceived;&#8221;.  This is still shorthand &#8212; the verbose way of saying this is to do &#8220;p.OutputDataReceived += new OutputDataReceivedEventHandler(OnOutputDataReceived);&#8221;</p>
<p>They&#8217;re all equivalent in terms of the compiled code, but hooking up anonymous methods directly to the events can come in handy.</p>
<p>You&#8217;ll probably need the ErrorDataReceived event: <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.errordatareceived.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.diagnostics.process.errordatareceived.aspx</a><br />
You could also just hook into this event and add the text to the same text box if you wanted.  (i.e. put but stderr and stdout into the same box).</p>
<p>As for piping text into the input stream, I think you can hook up a StreamWriter to the StandardInput stream: <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/system.diagnostics.process.standardinput.aspx</a></p>
<p>Hope that helps!  I&#8217;d be really interested in seeing your final demo showing how to read/write to all 3 streams <img src='http://thevalerios.net/matt/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Tribley</title>
		<link>http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/comment-page-1/#comment-523</link>
		<dc:creator>Bill Tribley</dc:creator>
		<pubDate>Fri, 29 Aug 2008 14:29:26 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/#comment-523</guid>
		<description>Way cool. I want to expand it. I am writing a ClearCase client for the masses, right now I fire an ugly command window that has pauses so you can see the errors and text inputs for some yes/no and other simple console input.

I want to add a much smaller (3-line high) stderr window, and a single line with a Send button so someone can send text to stdin. I would simply deactivate the run button and input command line. 

However, I do not understand this construct:

            p.OutputDataReceived += (o, args) =&gt;                        

                {

                    string text = args.Data + Environment.NewLine;

                    uiThread.Invoke(() =&gt;

                        {

                            txtOutput.AppendText(text);

                        });

                };

What does this (o,args) =&gt; { block } syntax mean? 

I&#039;ll submit my code if I can get it to work.</description>
		<content:encoded><![CDATA[<p>Way cool. I want to expand it. I am writing a ClearCase client for the masses, right now I fire an ugly command window that has pauses so you can see the errors and text inputs for some yes/no and other simple console input.</p>
<p>I want to add a much smaller (3-line high) stderr window, and a single line with a Send button so someone can send text to stdin. I would simply deactivate the run button and input command line. </p>
<p>However, I do not understand this construct:</p>
<p>            p.OutputDataReceived += (o, args) =&gt;                        </p>
<p>                {</p>
<p>                    string text = args.Data + Environment.NewLine;</p>
<p>                    uiThread.Invoke(() =&gt;</p>
<p>                        {</p>
<p>                            txtOutput.AppendText(text);</p>
<p>                        });</p>
<p>                };</p>
<p>What does this (o,args) =&gt; { block } syntax mean? </p>
<p>I&#8217;ll submit my code if I can get it to work.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Steven</title>
		<link>http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/comment-page-1/#comment-326</link>
		<dc:creator>Steven</dc:creator>
		<pubDate>Sat, 09 Aug 2008 21:57:00 +0000</pubDate>
		<guid isPermaLink="false">http://thevalerios.net/matt/2008/08/monitor-a-process-asynchronously-more-delegatemarshaler-tricks/#comment-326</guid>
		<description>Very nice!</description>
		<content:encoded><![CDATA[<p>Very nice!</p>
]]></content:encoded>
	</item>
</channel>
</rss>
