How to change to API2? YieldToNextThread and StrComp


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:

  1. 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

Do I simple replace “App.YieldToNextThread” with “Thread.YieldToNext” or do I need to call it on an instance of a thread?

  1. 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 ) )
    prop.Value( self ) = j.Value( thisName )
  end if

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…


  1. Yes, use App.YieldToNextThread instead.

  2. Yes, your code for compare is correct.

Thanks! :blush: 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!


Heheh… yes, the mids are tricky. I’m converting those one by one so that I can test.

Either will work, but the point of a shared method is that it can be called without having an instance. So if you don’t already have an instance then don’t bother with creating one just to call this method.