StrokesPlus.net
Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
johnwang  
#1 Posted : Tuesday, April 28, 2020 9:33:59 PM(UTC)
johnwang

Rank: Member

Reputation:

Groups: Approved
Joined: 4/2/2020(UTC)
Posts: 11
United States

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
I was wondering if someone would be able to help me with this CLR call that seems to be failing when called from a script:

var perfCounter = clr.System.Diagnostics.PerformanceCounter("Processor","% Processor Time", "_Total");
^^^causes invalid generic type argument exception

var perfCounter = clr.System.Diagnostics.PerformanceCounter;
perfCounter.CategoryName="Processor";
perfCounter.CounterName="% Processor Time";
perfCounter.InstanceName= "_Total";
^^^causes object has no suitable property or field named ... exception

Both these calls are documented in the system.diagnostics class.. am I missing something?

Basically what I'm trying to do is to automate an action in visual studio and save once processing is done and the only way I can know that is to check the cpu usage of the process. I can write another program to execute on action and exit when the devenv cpu usage drops but it would be nice to be able to do it all within the scripting engine
liuxilu  
#2 Posted : Wednesday, April 29, 2020 5:02:54 AM(UTC)
liuxilu

Rank: Advanced Member

Reputation:

Groups: Translators, Moderators, Approved
Joined: 4/6/2020(UTC)
Posts: 79
China

Thanks: 1 times
Was thanked: 21 time(s) in 21 post(s)
You forget 'new'
thanks 1 user thanked liuxilu for this useful post.
johnwang on 4/29/2020(UTC)
liuxilu  
#3 Posted : Wednesday, April 29, 2020 5:07:31 AM(UTC)
liuxilu

Rank: Advanced Member

Reputation:

Groups: Translators, Moderators, Approved
Joined: 4/6/2020(UTC)
Posts: 79
China

Thanks: 1 times
Was thanked: 21 time(s) in 21 post(s)
You may think of other ways, since you know the process's done not by CPU usage...
johnwang  
#4 Posted : Wednesday, April 29, 2020 2:51:10 PM(UTC)
johnwang

Rank: Member

Reputation:

Groups: Approved
Joined: 4/2/2020(UTC)
Posts: 11
United States

Thanks: 4 times
Was thanked: 1 time(s) in 1 post(s)
Thanks for your help! Yeah, it is a bit janky.

Basically this script executes the shortcut to add a function call to a code map.. waits for the visual studio process to drop to 0% cpu usage to indicate that it's done, saves the updated map, then navigates back to where I was before so I can continue adding functions.

Not pretty, but for engineering code, it'll do

Edited by user Wednesday, April 29, 2020 3:20:13 PM(UTC)  | Reason: Not specified

Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.