Timer刷新问题
功能:
用定时器,每隔多少秒刷新path下文件内容到Textbox
VS2010的Windows Froms Application
这是在button1_Click中的方法
refrushClass类(与public ref class Form1 : public System::Windows::Forms::Form在同一源码中):
设计思路:
通过TimerEventProcessor方法来定时读取Path中的内容,但不知道如何传递到textbox控件中
用定时器,每隔多少秒刷新path下文件内容到Textbox
VS2010的Windows Froms Application
这是在button1_Click中的方法
//调用刷新方法来定时分析数据
refrushClass^ re = gcnew refrushClass;
path = "c:\\SceneServer.log5696";
re->Main(path);refrushClass类(与public ref class Form1 : public System::Windows::Forms::Form在同一源码中):
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();
}
}
};
设计思路:
通过TimerEventProcessor方法来定时读取Path中的内容,但不知道如何传递到textbox控件中
...全文
相关推荐
Ajax Timer异步刷新实例
Ajax Timer介绍Ajax Timer是一个特殊的组件,它结合了AJAX技术和计时器功能,能够在预设的时间间隔内自动发送AJAX请求到服务器,获取更新的信息并刷新页面的特定区域。
页面自动刷新
- 考虑到网络状况和服务器性能,通常情况下,1-10秒的刷新间隔更为合理。通过上述内容,我们了解了如何使用VB创建一个页面自动刷新器,并对其潜在的性能和用户体验问题进行了讨论。
Timer Refresh-crx插件
通过设置合适的刷新间隔,用户可以在保持工作效率的同时,保持对关键信息的关注。此外,CRX插件的安全性和隐私问题也是值得讨论的。
关于ajax 和timer组成的无刷新操作的web小程序
本篇文章将深入探讨如何结合Ajax(异步JavaScript和XML)与Timer来构建一个无刷新操作的Web小程序,特别是针对登录功能的实现。
MFC中一个定时器程序(1s刷新一次)
- 如果定时器操作涉及到UI更新,确保在主线程中执行,避免跨线程访问控件可能导致的问题。这个简单的MFC定时器程序可以帮助你在每秒间隔执行特定任务,如刷新数据显示、执行后台计算等。


VC.NET
