It is currently December 3rd, 2020, 10:58 am

[help] C# and multithreading

Share and get help with Plugins and Addons
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [help] C# and multithreading

Post by jsmorley »

I can't really test with that abort still left in the Dispose() function, as that is indeed called when the skin is refreshed (as well as when unloaded), so we still have the issue.
User avatar
Aragas
Posts: 64
Joined: December 24th, 2012, 6:56 pm
Location: Russia, Moscow

Re: [help] C# and multithreading

Post by Aragas »

jsmorley wrote:I can't really test with that abort still left in the Dispose() function, as that is indeed called when the skin is refreshed (as well as when unloaded), so we still have the issue.
Fixed. Uploaded.
So, you are saying, Finalize() is called by skin refresh?
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [help] C# and multithreading

Post by jsmorley »

Aragas wrote: Fixed. Uploaded.
So, you are saying, Finalize() is called by skin refresh?
Correct.
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [help] C# and multithreading

Post by jsmorley »

Built your code and am running it. Not sure how to really test other than to let it run and refresh the crap out of it to see if it ever "hangs".

On a side note, FinishAction is never executed with the change you made to that.
User avatar
Aragas
Posts: 64
Joined: December 24th, 2012, 6:56 pm
Location: Russia, Moscow

Re: [help] C# and multithreading

Post by Aragas »

jsmorley wrote:Built your code and am running it. Not sure how to really test other than to let it run and refresh the crap out of it to see if it ever "hangs".

On a side note, FinishAction is never executed with the change you made to that.
I just don't have your skin code, so i can't test FinishAction.
Compiled and runned. Seems to work.
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [help] C# and multithreading

Post by jsmorley »

Aragas wrote: I just don't have your skin code, so i can't test FinishAction.
Compiled and runned. Seems to work.
Let me test further. I may have had an unstable instance of the dll still in memory when I restarted things.
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [help] C# and multithreading

Post by jsmorley »

So far so good. The issue with FinishAction isn't that it doesn't run at all, it is that it is one update of the measure "behind", so if I have a CheckNet measure with a FinishAction on it that enables a calc measure that tests the value and takes some action, that calc measure is not enabled until after the "second" time the plugin runs.

Some logic flaw in how we are doing FinishAction. It should fire in the skin as soon as the plugin measure completes and some value is returned.
User avatar
Aragas
Posts: 64
Joined: December 24th, 2012, 6:56 pm
Location: Russia, Moscow

Re: [help] C# and multithreading

Post by Aragas »

jsmorley wrote:So far so good. The issue with FinishAction isn't that it doesn't run at all, it is that it is one update of the measure "behind", so if I have a CheckNet measure with a FinishAction on it that enables a calc measure that tests the value and takes some action, that calc measure is not enabled until after the "second" time the plugin runs.

Some logic flaw in how we are doing FinishAction. It should fire in the skin as soon as the plugin measure completes and some value is returned.
Hm. Strange. Have done some fixes, try the latest commit, maybe will work.
UPD:
Can you tell me what you put in FinishAction in your skin? Maybe it's a problem with letters register.
User avatar
jsmorley
Developer
Posts: 21521
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [help] C# and multithreading

Post by jsmorley »

It gets worse.. ;-)

If you have a skin with two CheckNet plugin measures in it, one doing "network" and one "doing" internet, the second one is just never executed at all.

If you try this skin:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Variables]
Green=139,235,136,255
Red=209,104,96,255

[MeasureNetwork]
Measure=Plugin
Plugin=CheckNet
ConnectionType=Network
UpdateRate=5
FinishAction=[!EnableMeasure MeasureNetworkCheck][!UpdateMeasure MeasureNetworkCheck]

[MeasureNetworkCheck]
Measure=Calc
Formula=MeasureNetwork
IfAboveValue=0
IfAboveAction=[!SetOption MeterNetwork SolidColor #Green#][!UpdateMeter *][!Redraw]
IfBelowValue=0
IfBelowAction=[!SetOption MeterNetwork SolidColor #Red#][!UpdateMeter *][!Redraw]
UpdateDivider=-1
Disabled=1

[MeasureInternet]
Measure=Plugin
Plugin=CheckNet
ConnectionType=Internet
UpdateRate=20
FinishAction=[!EnableMeasure MeasureInternetCheck][!UpdateMeasure MeasureInternetCheck]

[MeasureInternetCheck]
Measure=Calc
Formula=MeasureInternet
IfAboveValue=0
IfAboveAction=[!SetOption MeterInternet SolidColor #Green#][!UpdateMeter *][!Redraw]
IfBelowValue=0
IfBelowAction=[!SetOption MeterInternet SolidColor #Red#][!UpdateMeter *][!Redraw]
UpdateDivider=-1
Disabled=1

[MeterNetwork]
Meter=Image
W=20
H=20
SolidColor=150,150,150,255

[MeterInternet]
Meter=Image
X=3R
W=20
H=20
SolidColor=150,150,150,255
It won't work correctly at all. Leaving aside the fact that the FinishAction is one measure update behind for the moment, we can come back to that, what happens is that the [MeasureInternet] measure never executes (at least it never receives any value from the plugin).

If I have only one CheckNet measure, either kind, it works fine.

If I "disabled" the second one, and have a FinishAction on the first one "enable" the second one:

Code: Select all

[Rainmeter]
Update=1000
AccurateText=1
DynamicWindowSize=1

[Variables]
Green=139,235,136,255
Red=209,104,96,255

[MeasureNetwork]
Measure=Plugin
Plugin=CheckNet
ConnectionType=Network
UpdateRate=5
FinishAction=[!EnableMeasure MeasureNetworkCheck][!UpdateMeasure MeasureNetworkCheck]

[MeasureNetworkCheck]
Measure=Calc
Formula=MeasureNetwork
IfAboveValue=0
IfAboveAction=[!SetOption MeterNetwork SolidColor #Green#][!UpdateMeter *][!EnableMeasure MeasureInternet][!Redraw]
IfBelowValue=0
IfBelowAction=[!SetOption MeterNetwork SolidColor #Red#][!UpdateMeter *][!Redraw]
UpdateDivider=-1
Disabled=1

[MeasureInternet]
Measure=Plugin
Plugin=CheckNet
ConnectionType=Internet
UpdateRate=20
Disabled=1
FinishAction=[!EnableMeasure MeasureInternetCheck][!UpdateMeasure MeasureInternetCheck]

[MeasureInternetCheck]
Measure=Calc
Formula=MeasureInternet
IfAboveValue=0
IfAboveAction=[!SetOption MeterInternet SolidColor #Green#][!UpdateMeter *][!Redraw]
IfBelowValue=0
IfBelowAction=[!SetOption MeterInternet SolidColor #Red#][!UpdateMeter *][!Redraw]
UpdateDivider=-1
Disabled=1

[MeterNetwork]
Meter=Image
W=20
H=20
SolidColor=150,150,150,255

[MeterInternet]
Meter=Image
X=3R
W=20
H=20
SolidColor=150,150,150,255
Then it works fine. You just can't have two copies of CheckNet both executed at the same time.
User avatar
Aragas
Posts: 64
Joined: December 24th, 2012, 6:56 pm
Location: Russia, Moscow

Re: [help] C# and multithreading

Post by Aragas »

I think i can easy fix that. My method with switch can handle with it. I'll make it tomorrow if you don't mind.