ThreadPriority

  • Thread starter Thread starter Mobileboy36
  • Start date Start date
M

Mobileboy36

Hello group,


How can I specify the threadpriority in a string (comming from a configfile)
without using a structure like the following (To convert a string to a type,
you can use the activator, is that also the solution for my question) ?



Select Case strThreadPriority
Case "AboveNormal"
MyThrPrior = Threading.ThreadPriority.AboveNormal
Case "BelowNormal"
MyThrPrior = Threading.ThreadPriority.BelowNormal
Case "Highest"
MyThrPrior = Threading.ThreadPriority.Highest
Case "Lowest"
MyThrPrior = Threading.ThreadPriority.Lowest
Case "Normal"
MyThrPrior = Threading.ThreadPriority.Normal
End Select


Best regards,
Mobile boy
 
Mobileboy36 said:
Hello group,


How can I specify the threadpriority in a string (comming from a
configfile) without using a structure like the following (To convert
a string to a type, you can use the activator, is that also the
solution for my question) ?



Select Case strThreadPriority
Case "AboveNormal"
MyThrPrior = Threading.ThreadPriority.AboveNormal
Case "BelowNormal"
MyThrPrior = Threading.ThreadPriority.BelowNormal
Case "Highest"
MyThrPrior = Threading.ThreadPriority.Highest
Case "Lowest"
MyThrPrior = Threading.ThreadPriority.Lowest
Case "Normal"
MyThrPrior = Threading.ThreadPriority.Normal
End Select

Have a look at [Enum].Parse


Armin
 
Mobileboy36 said:
How can I specify the threadpriority in a string (comming from a
configfile) without using a structure like the following (To convert a
string to a type, you can use the activator, is that also the solution for
my question) ?

Select Case strThreadPriority
Case "AboveNormal"
MyThrPrior = Threading.ThreadPriority.AboveNormal
Case "BelowNormal"
MyThrPrior = Threading.ThreadPriority.BelowNormal

\\\
Imports System.Threading
....
Dim PriorityString As String = ...
Dim Priority As ThreadPriority = _
DirectCast( _
[Enum].Parse(GetType(ThreadPriority), PriorityString), _
ThreadPriority _
)
///
 
Back
Top