I was going to "chime" into conversation a little earlier, but I thought maybe you might be going in a different direction. Plus, my plugin is written in C++ and not C# (which I am unfamiliar with, so I wasn't much help).FlyingHyrax wrote:Well, I feel rather silly: I totally missed this.
I think you are on the right track. Although I don't think Rainmeter will have trouble with spawning a new thread on every Update cycle, I think that will be overkill. In the context of of a Rainmeter plugin, I think threads are only needed to perform "expensive" (or timely) operations that "block" Rainmeter from executing normally.jsmorley wrote:Poiru or Brian may have a better feel for this due to their experiences with threads in C++ in the context of Rainmeter.
This is basically how Webparser and some other threaded plugins work when it comes to "when" a thread should be spawned. The trickier part is how to tell the spawned thread that the plugin is no longer loaded; how to assign some value back to the Rainmeter thread (usually using some sort of mutex or critical section); and how to have the spawned thread unload the plugin in case the skin is closed before the spawned thread is finished. It can get very complex quickly, usually requiring more code then you first planned on.jsmorley wrote:The flow to me sorta feels like:
Code: Select all
Update() If UpdateCounter is zero Start thread Execute actions Thread ends and plugin value is set when actions are finished Else Skip thread and actions Endif Increment UpdateCounter If UpdateCounter is equal to UpdateRate Set UpdateCounter to zero Endif Return existing or new plugin value from actions.
Remember that you need to "lock" any shared data between threads with a mutex or critical section - not just inside your thread.
I wish I could be more help, but I really don't know C# at all.
-Brian