logging - Continuously update control (listBox) from live feed (file) c# -
i'm doing small app reads log file continuously updated, parses , shows relevant information.
i started doing prototype in console app , working smoothly. i'm totally stuck when trying to, instead of outputting console, trying control (a listbox in case).
the ui freezes read never ends thou async method , works flawlessly console app.
i'm trying find information not sure if have run background workers or kind of approach should make.
the current situation follows:
- win form controls
- class handles reading
the class works said console app. reads continuously file , parses information , outputs if instead outputting try add info listbox, ui freezes.
quick update:
the async method enclosed while(almostalwaystrue) that's reading new data if there is.
hope clear. appreciated.
thanks.
i used filesystemwatcher. log created first read , instantiate watcher. whenever change, watcher reads last point. ran different problem.
i couldn't access ui elements instantiated in different thread fixed it:
if (this._listbox.invokerequired) this._listbox.invoke(new methodinvoker(delegate { this._listbox.items.add(newitem); })); else this._listbox.items.add(newitem);
so have going me nice :)
Comments
Post a Comment