It is currently April 19th, 2024, 6:02 pm

[help] C# and multithreading

Share and get help with Plugins and Addons
User avatar
Aragas
Posts: 64
Joined: December 24th, 2012, 6:56 pm

Re: [help] C# and multithreading

Post by Aragas »

See my fork.
I wrote it with my experience with Rainmeter and multithreading. I think it is very good and so it must be in samples. I have renamed values, it looks now like a sample.
What i want say: I think jsmorley is right, maybe there is a way to make just ReturnVaruable. I will see what i can do.
I want to know every your note about this code :sly:

And i think it can't be broken with interaction in Rainmeter. (haha)

Firstblood:
*Counter don't work. Thread is created by every update or something like that.
Fixed. Used ReturnValue. But keeped separated options. In progress.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [help] C# and multithreading

Post by jsmorley »

On looking at things and talking a bit to poiru, I don't think we want to create the threads in Reload(). That is going to cause issues with how the actual measure in the skin is updated with the current value unless DynamicVariables is always used on the measure.

I need to take a break from this for a while. I have a sense that what your code is doing is more than what is needed, but to be honest I'm having a hard time following it. I get so irritated with the numerous different naming conventions for functions and variables, and the way that the term "cancel" is used in 20 different places with no naming that makes it clear what they are or what they do, that I kinda give up.

I have no idea why we would use such a mess of "_variableName", "VariableName" "variablename", "variableName", and exactly what is a "Ruly"? ;-)
User avatar
Aragas
Posts: 64
Joined: December 24th, 2012, 6:56 pm

Re: [help] C# and multithreading

Post by Aragas »

jsmorley wrote:On looking at things and talking a bit to poiru, I don't think we want to create the threads in Reload(). That is going to cause issues with how the actual measure in the skin is updated with the current value unless DynamicVariables is always used on the measure.

I need to take a break from this for a while. I have a sense that what your code is doing is more than what is needed, but to be honest I'm having a hard time following it. I get so irritated with the numerous different naming conventions for functions and variables, and the way that the term "cancel" is used in 20 different places with no naming that makes it clear what they are or what they do, that I kinda give up. I have no idea why we would use such a mess of "_variableName", "VariableName" "variablename", and exactly what is a "Ruly"?
Yea, i understand that. My code is always hard to read :D
Ruly is our alternative for Thread.Abord(); You wrote it caused a problem, so we fixed it.
Hm. We can then just see if DynamicVariables is used. If not, hen create a Thread in Update().
cancel is a part from Ruly to safely close Thread.
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [help] C# and multithreading

Post by jsmorley »

Why the term "Ruly"? Did you just open a dictionary to a random page and point at a word? ;-)
User avatar
Aragas
Posts: 64
Joined: December 24th, 2012, 6:56 pm

Re: [help] C# and multithreading

Post by Aragas »

It's a standart:
_variableName is for private variables
VariableName for public
variablename...must be a typo
User avatar
Aragas
Posts: 64
Joined: December 24th, 2012, 6:56 pm

Re: [help] C# and multithreading

Post by Aragas »

jsmorley wrote:Why the term "Ruly"? Did you just open a dictionary to a random page and point at a word? ;-)
Nope, just copied this
http://www.albahari.com/threading/part3.aspx#_Abort
:sly:

We can rename it if it don't match.
FlyingHyrax
Posts: 232
Joined: July 1st, 2011, 1:32 am
Location: US

Re: [help] C# and multithreading

Post by FlyingHyrax »

The canceler is from here, and the name is from here. (Think "unruly".) Though you're right, I'm not sure it's actually needed for something this lightweight.

Also, '_someVar' is just a convention for private variables in C#, because of the way it handles class field access. '_someVar' is the private field, 'SomeVar' is it's public accessor/mutator.

Update: Beaten to the punch.
Flying Hyrax on DeviantArt
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [help] C# and multithreading

Post by jsmorley »

Aragas wrote:It's a standart:
_variableName is for private variables
VariableName for public
variablename...must be a typo
Ok, not any standard I have ever used, but to each his own.

http://msdn.microsoft.com/en-us/library/ff926074.aspx
User avatar
jsmorley
Developer
Posts: 22629
Joined: April 19th, 2009, 11:02 pm
Location: Fort Hunt, Virginia, USA

Re: [help] C# and multithreading

Post by jsmorley »

Anyway, arguing about naming conventions is the road to hell. ;-)
User avatar
Aragas
Posts: 64
Joined: December 24th, 2012, 6:56 pm

Re: [help] C# and multithreading

Post by Aragas »

You know, all our problem caused because Rainmeter is using .net 2.0
Can we upgrade this at least to 3.5? There are async methods that we could use and say goodbye to threads.