7,540
社区成员
发帖
与我相关
我的任务
分享
//调用刷新方法来定时分析数据
refrushClass^ re = gcnew refrushClass;
path = "c:\\SceneServer.log5696";
re->Main(path);
public ref class refrushClass
{
private:
static System::Windows::Forms::Timer^ myTimer = gcnew System::Windows::Forms::Timer;
static int alarmCounter = 1;
static String^ pathRefrush;
static String^ strTotal;
// This is the method to run when the timer is raised.
static void TimerEventProcessor( Object^ /*myObject*/, EventArgs^ /*myEventArgs*/ )
{
myTimer->Stop();
myTimer->Enabled = true;
//读取path文件内容
StreamReader^ sr = File::OpenText(pathRefrush);
try
{
//临时存放每次读取到的文件
String^ s = "";
while (s = sr->ReadLine())
{
strTotal += s;
}
}
finally
{
if (sr)
{
//释放缓存文件
delete (IDisposable^)(sr);
}
}
/*不知道怎么把strTotal传递到指定的textbox中,textbox无法直接在此引用*/
}
public:
static void Main(String^ path)
{
pathRefrush = path;
/* Adds the event and the event handler for the method that will
process the timer event to the timer. */
myTimer->Tick += gcnew EventHandler( TimerEventProcessor );
// Sets the timer interval to 5 seconds.
myTimer->Interval = 5000;
myTimer->Start();
// 调用TimerEventProcessor()方法
while(true)
{
Application::DoEvents();
}
}
};