The form code:
Public partial class MainFrame: Form
{
Private static XmlDocument xmlDoc=new XmlDocument ();
Public MainFrame ()
{
InitializeComponent ();
}
GetTime dt=new GetTime ();
Public void the start ()
{
ReadLog (" System Start Running... \n");
ReadLog (" database connection success... \n");
AutoProcessThread autopt=new AutoProcessThread ();
The Thread of td=new Thread (autopt. Run);
//run a method of cs file
Td. Start ();
}
Public void readLog (string log)
{
String time=dt. DateTime ();
TextBox1. AppendText (time + log + "\ n");
}
}
}
The class AutoProcessThread
{
Public void the run ()
{
MainFrame mf=new MainFrame ();
Mf. ReadLog (" enter autoProcess -- -- -- -- -- - run ");
}
}
So the question comes, why call readLog method can display in the form in the textBox, while other cs file called mf. ReadLog (" enter autoProcess -- -- -- -- -- - run ") are not shown on the textBox form?
CodePudding user response:
Someone give you a answerCodePudding user response:
Since you have no showDialog,The class AutoProcessThread
{
Public void the run ()
{
MainFrame mf=new MainFrame ();
Mf. ReadLog (" enter autoProcess -- -- -- -- -- - run ");
mf. ShowDialog ();
}
}
CodePudding user response:
Log is not much, just do a timer brush,String s=File. ReadAllText (log filename);
If (s!=textBox1. Text)
TextBox1. Text=s;
CodePudding user response: