مراقبة البرامج الجارية

كيفية مراقبة برنامج جاري

يعرض الكود العينة التالي كيفية رصد برنامج تشغيل. يمكن استخدام هذا الكود لمراقبة تنفيذ الفصول الدراسية المتعلق بالبرنامج. ببساطة، استخدم فئة SystemTimeInterruptMonitor لإنشاء كائن مراقبة، استخدم وظيفة SetInterruptMonitor لإضافتها إلى LoadOptions معلمات التشغيل، ثم استخدم وظيفة StartMonitor لتعيين الوقت المتوقع للانقطاع (بالميلي ثانية) . إذا تجاوز وقت تشغيل الكود المراقب الوقت المتوقع، سيتم إيقاف التشغيل وسيتم رمي استثناء.

الكود المثالي

Aspose::Cells::Startup();
SystemTimeInterruptMonitor monitor(false);
LoadOptions lopts;
lopts.SetInterruptMonitor((AbstractInterruptMonitor*) & monitor);
monitor.StartMonitor(1000); //time limit is 1 second
Workbook wb(u"Large.xlsx", lopts);
//if the time cost of loading the template file exceeds one second, interruption will be required and exception will be thrown here
//otherwise starts to monitor the save procedure
monitor.StartMonitor(1500); //time limit is 1.5 seconds
wb.Save(u"result.xlsx");
Aspose::Cells::Cleanup();