|
This code works, but it waits until the program is done running to display anything.
namespace Taynia_Updater
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.ProcessStartInfo sinf = new System.Diagnostics.ProcessStartInfo("cmd", "/c php taynia.php");
sinf.RedirectStandardOutput = true;
sinf.UseShellExecute = false;
sinf.CreateNoWindow = true;
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = sinf;
p.Start();
string res = p.StandardOutput.ReadToEnd();
Console.WriteLine(res);
Console.ReadLine();
}
}
}
This is what i am trying to do (I am not familiar with C#, mostly php)
namespace Taynia_Updater
{
class Program
{
static void Main(string[] args)
{
System.Diagnostics.ProcessStartInfo sinf = new System.Diagnostics.ProcessStartInfo("cmd", "/c php taynia.php");
sinf.RedirectStandardOutput = true;
sinf.UseShellExecute = false;
sinf.CreateNoWindow = true;
System.Diagnostics.Process p = new System.Diagnostics.Process();
p.StartInfo = sinf;
p.Start();
while (Res = p.StandardOutput.Read())
{
Console.WriteLine(res);
}
Console.ReadLine();
}
}
}
Basically, I just want to be able to stream output of running a command, heck, even running the tree command on the C: drive, i'd like to watch it being done through C#, and not wait for it to be executed, then print it all out at once. Is this even possible?
|
|
|
|
|
I think you can use the event Exited in the Process class, so once the process
finishes you can get the output you want.
Sincerely Samer Abu Rabie
Note: Please remember to rate this post to help others whom reading it.
|
|
|
|
|
I know i can do that, but i dont want to wait for the process to end before i get the out put, i want to write it to the console as it comes. stream it...
|
|
|
|
|
Look at the OutputDataReceived event. IIRC it fires for every line it receives.
xacc.ide - now with TabsToSpaces support IronScheme - 1.0 beta 1 - out now! ((lambda (x) `((lambda (x) ,x) ',x)) '`((lambda (x) ,x) ',x))
|
|
|
|
|
Hi,
yes you can capture stdout and stderr outputs from another process while it is still running, which gives
a much better user experience than performing a ReadToEnd() and wait until the process has exited.
The general solution requires two extra threads, basically identcial, one to handle stdout and one to handle stderr.
Each thread should loop and read its stream, and process it in any way you see fit.
Both threads should be terminated a few seconds AFTER your target process has exited, there still is data
in the stream when the process exits!
I got this to work easily on XP and Vista, but found it impossible coming up with code that would also run
fine on Win98 (that was on .NET 1.1 at the time).
|
|
|
|
|
Hi,
I wrote an application that able to connect another bluetooth device in .Net Framework 2.0 using bluetooth API, now I want to do this with .Net Compact Framework on my mobile device. That's the problem, When I'm Calling Bluetooth API like WSAStartup or using SizeOf or any other methods of Marshal class, it gives me NotSupportedException exception.
Please tell me how can i solve this problem.
Thank you.
DMASTER
|
|
|
|
|
Please do not cross post
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Now what do YOU think 'not supported' means ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi dear Christian,
I know what it means BROTHER , if you refer to MSDN you can see that, it's marked as supported on .net CF. But I don't know what's that exception reason, and why gives it to me?
Thanks for your reply.
|
|
|
|
|
Hi,
there are several WSA versions, not all of them are implemented on each platform.
This might help you.[^]
modified on Wednesday, December 3, 2008 4:15 AM
|
|
|
|
|
Hi Luc,
Ok, Let's suppose you're right. So what about Marshalling and methods of Marshal Class ?
|
|
|
|
|
Marshaling what? SizeOf what? something that is not supported maybe?
check the exact exception, note the line numbers, look at the source code, teach your IDE to display line numbers. Try to be as specific as you want the answers to be.
|
|
|
|
|
I have kind of a hard task here. I built a WPF App that uses a MSSQL 2000 database. The info comes in from a Base Table and two join tables. because of this I had to build a datatable to "flaten" out the data. So each Base and have many tools and each tool has its own Gridview column that I creat in C# on the fly so if I add more tools the coloumns we be auto created. This works great. The Info displayed is Either Rerun the date the tool will be used or the date the tool will be off. Now what I need to do is change the color of the cell to if rerun then be red if the date the tool is on then green and date off lets say gray.
I am trying to use the code behind to try a datatemplate but I am not understanding how that works.
|
|
|
|
|
First of all ... this post should have been placed under ASP.NET not C# .. no problem you probably missed that
Anyway ... for a grid view ... you can try using the ItemDataBound event for the grid view to change the cell color or format the cell if you wanted ... search for it and you will know how to use ItemDataBound event.
Sincerely Samer Abu Rabie
Note: Please remember to rate this post to help others whom reading it.
|
|
|
|
|
Samer Abu Rabie wrote: this post should have been placed under ASP.NET
Ummmm, OP wrote: I built a WPF App that uses a MSSQL 2000 database, so would be better in the WPF forum
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Oops ... I don't know how come I saw it an ASP.NET application .. sorry Mr. jesse34 ... my bad ... my solution was upon ASP.NET not WPF
Sincerely Samer Abu Rabie
Note: Please remember to rate this post to help others whom reading it.
|
|
|
|
|
Samer Abu Rabie wrote: don't know how come I saw it an ASP.NET application
It happens. I wonder if the ASP.NET solution would be the same in WPF
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
Mmmmm ... Actually I don't think so, its not the same grid control, and I haven't got deep enough in WPF to answer him ... but certainly I will give it a shot in a spare time of mine
Sincerely Samer Abu Rabie
Note: Please remember to rate this post to help others whom reading it.
|
|
|
|
|
Samer Abu Rabie wrote: its not the same grid control, and I haven't got deep enough in WPF to answer him ...
Me neither. Trying to get more into WPF, I mean I've read all of Josh Smith's articles and Sacha Barber's, as well. Getting there
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
"Not only do you continue to babble nonsense, you can't even correctly remember the nonsense you babbled just minutes ago." - Rob Graham
|
|
|
|
|
You know something ... I might do the same too ... I believe the challenge is not the code practices itself as of using the WPF Controls since their presentation on the form is of XML, the grid control is an example ... it seems that the .NET Framework doesn't have one and there are a lot of articles speaks of using a third party control or something like that !
Anyway ... I would defiantly put this as a self training material ... and maybe when I know something I will get back to this post and figure out a solution to Mr. Jesse34
Sincerely Samer Abu Rabie
Note: Please remember to rate this post to help others whom reading it.
|
|
|
|
|
I want to thank both of you for looking into this. Like I said I am new to WPF as well and this boogles my mind.
|
|
|
|
|
I can see maybe the WPF thread .. but I am using C# as my code behind. The is neither here nor there. I am wonding on this ItemDataBound event. Can you give a simple example is it a Method of the GridView?
|
|
|
|
|
I've developed one small school project(windows project) now I've to deliver my project to my client.If my cient was trying to install it more than once in some of system it should ask some serial code or it should raise not more than once.Simply my project has to install only once.Again trying to install in other systems it should ask serial keys or watever so how to do these settings to my project(is there any chance to set in click once deployment).
It's too urgent for me.........thank u for ur quick response.
|
|
|
|
|
Roney wrote: Simply my project has to install only once.
Set an machine registry key on install and check it before install.
Roney wrote: is there any chance to set in click once deployment
ClickOnce only simplifies the deployment from a single point, it does not solve single installation completely.
|
|
|
|
|
Yes i thought like this whatever u have told.........but how to set registry key and where it is to be set......plz help me it is very urgent.
|
|
|
|