Hi,
I am trying to convert all the deprecated code in Kaju Updater that I’ve incorporated into my project over to use API2. There are 2 functions I’m uncertain of how to implement the equivalent API2 code. If someone could tell me if this is correct or not, that would be much appreciated:
- App.YieldToNextThread
API2 equivalent: Thread.YieldToNext () (Shared Method)
Implemented in Kaju.UpdateInitiater.RunScriptLinux, .RunScriptMac, .RunScriptWindows
//
// Run the script
//
Var sh As New Shell
'sh.Mode = 1 // Asynchronous
sh.ExecuteMode = Shell.ExecuteModes.Asynchronous
Var cmd as string
cmd = "/usr/bin/nohup " + ShellQuote( scriptFile.NativePath ) + " &"
sh.Execute( cmd )
Var targetTicks as integer = System.Ticks + 60
while System.Ticks < targetTicks
sh.Poll
App.YieldToNextThread
wend
Do I simple replace “App.YieldToNextThread” with “Thread.YieldToNext” or do I need to call it on an instance of a thread?
-
StrComp (string1 , string2 , mode )
API2 equivalent: String.Compare (other As String, Optional compare As ComparisonOptions = comparisonOptions.CaseInsensitive, Optional locale As Locale = Nil) As Integer
Implemented in Kaju.UpdateChecker.LoadPrefs, .ProcessRaw, .SavePrefs
Var j as new JSONItem( raw )
//
// Load the individual variables here
//
Var ti as Introspection.TypeInfo = Introspection.GetType( self )
Var props() as Introspection.PropertyInfo = ti.GetProperties
for each prop as Introspection.PropertyInfo in props
Var thisName as string = prop.Name
If StrComp( thisName.Right( 4 ), "Pref", 0 ) <> 0 Or Not j.HasKey( prop.Name ) Then
continue for prop
end if
if prop.PropertyType.Name = "String()" then
prop.Value( self ) = JSONToStringArray( j.Value( thisName ) )
else
prop.Value( self ) = j.Value( thisName )
end if
next
My understanding is that StrComp mode 0 is binary (case-sensitive) comparison. So would the equivalent code be this?
If thisName.Right(4).Compare("Pref", ComparisonOptions.CaseSensitive) <> 0 Or Not j.HasKey( prop.Name ) Then
Continue For prop
End If
I don’t have a good enough understanding of the difference between binary and lexicographic comparison to be sure…
Thanks!
Frank
Just wanted to make sure that I didn’t create a hard to find error. I almost cocked it up when I followed the IDE’s suggestions and straight out converted mid and midB to Middle and MiddleBytes and FolderItem.Item to .ChildAt, then later realised that I needed to compensate for them being 1 and 0-based!