Skip to content
Snippets Groups Projects
Commit 4530e1d2 authored by Jiří Kalvoda's avatar Jiří Kalvoda
Browse files

refresh time in config

parent 3b597986
No related branches found
No related tags found
No related merge requests found
......@@ -186,6 +186,7 @@ namespace i3csstatus {
{
List<Module> modules;
long nextRun = 0;
long refresh_ms;
object nextRunMonitor = new();
public StatusBar(FileInfo configFile)
{
......@@ -196,6 +197,8 @@ namespace i3csstatus {
{
var p = new ConfigParser(File.ReadAllText(configFile.ToString()));
refresh_ms = (int)((p.MainSection["refresh"]?.AsDouble() ?? 1.0)*1000);
var moduleTypes = new Dictionary<string, Type>(
from assembly in AppDomain.CurrentDomain.GetAssemblies()
from type in assembly.GetTypes()
......@@ -248,13 +251,17 @@ namespace i3csstatus {
void wait()
{
lock(nextRunMonitor)
{
while(true)
{
long actual = Environment.TickCount64;
if(nextRun <= actual)
return;
break;
long wait_ms = Math.Min(10000, nextRun - actual);
Monitor.Wait(nextRunMonitor, (int)wait_ms, true);
}
nextRun = Environment.TickCount64 + refresh_ms;
}
}
public void Run(TextWriter w)
{
......@@ -262,7 +269,6 @@ namespace i3csstatus {
while(true)
{
wait();
nextRun = Environment.TickCount64 + 10000;
Print(w);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment