2016-04-06 23 views
0

私は現在のハッシュレートをEthereum(Bitcoinのような暗号化)に表示するアプリケーションを作成しています。実行中のコマンドラインから何とか連続出力を取得する必要があります。これは私がこれまで持っているものであるが、プログラム出力に印刷されていません。C#WPF読み込みコンソール出力

pProcess.OutputDataReceived += new DataReceivedEventHandler((sender, e) => 
{ 
    // Prepend line numbers to each line of the output. 
    if (!String.IsNullOrEmpty(e.Data)) 
    { 
     System.Console.Write(e.Data); 
    } 
}); 

//Wait for process to finish 
pProcess.WaitForExit(); 

このコードで作業していませんか?私は、イベントハンドラに何かが混乱していると推測していますが、私は何がわかりません。

+0

あなたは、任意のプロセスを呼び出しています?プロセスと同様aNewProcess = new Process(); – bluetoothfx

+0

ここで何が起こっているのか分かりにくいですが、あまりコードはありません。 –

+0

私はあなたに私達に詳細を与える必要があると思う。よろしければ。 – bluetoothfx

答えて

0

コピーしてあなたのコードに貼り付けて、私はあなたのためにそれを修正:

using System; 
using System.Collections.Generic; 
using System.Linq; 
using System.Text; 
using System.Threading.Tasks; 
using System.Windows; 
using System.Windows.Controls; 
using System.Windows.Data; 
using System.Windows.Documents; 
using System.Windows.Input; 
using System.Windows.Media; 
using System.Windows.Media.Imaging; 
using System.Windows.Navigation; 
using System.Windows.Shapes; 
using System.Diagnostics; 

    namespace ETHMinerVisualiser 
    { 
     /// <summary> 
     /// Interaction logic for MainWindow.xaml 
     /// </summary> 
     public partial class MainWindow : Window 
     { 
      public MainWindow() 
      { 
       InitializeComponent(); 
      } 

      private void MineButton_Click(object sender, RoutedEventArgs e) 
      { 
       Task.Run(() => { startMining(); }); 
      } 

      public void startMining() 
      { 
       //Create process 
       System.Diagnostics.Process pProcess = new System.Diagnostics.Process(); 

       //strCommand is path and file name of command to run 
       pProcess.StartInfo.FileName = @"E:/Documents/ETH/ETHMinerVisualiser/ethminer-cuda-0.9.41-new/ethminer.exe"; 

       //strCommandParameters are parameters to pass to program 
       pProcess.StartInfo.Arguments = "-F eu1.ethermine.org:5555/0x9c3f6281b123541f10c9bf37a8f273aa2a774d17.PCGPU -C"; 

       pProcess.StartInfo.UseShellExecute = false; 


       //Set output of program to be written to process output stream 
       pProcess.StartInfo.RedirectStandardOutput = true; 

       //Optional 
       pProcess.StartInfo.WorkingDirectory = ""; 

       //Start the process 
       pProcess.Start(); 

       //pProcess.StartInfo.CreateNoWindow = true; 

       //pProcess.BeginOutputReadLine(); 

       pProcess.OutputDataReceived += new DataReceivedEventHandler((sender, e) => 
       { 
        // Prepend line numbers to each line of the output. 
        if (!String.IsNullOrEmpty(e.Data)) 
        { 
         //System.Console.Write(e.Data);     
         Debug.WriteLine(e.Data); 
        } 
       }); 

       //Wait for process to finish 
       pProcess.BeginOutputReadLine(); 

       pProcess.WaitForExit(); 
      } 
     } 
    } 
+0

これはうまくいっていますが、これはうまくいきませんでしたD: – MattyAB

+0

プログラムの出力が「スレッド0x1448はコード0(0x0)で終了しました」と表示されません – MattyAB

+0

ここでうまくいきます。 ..スクリーン・ソート・ウェイティング – bluetoothfx

関連する問題