title: when to load pre-jit compilation in a windows form .net application?
body: <p>Following this answer
  <a href="https://stackoverflow.com/questions/5175743/preload-all-assemblies-jit">Preload all assemblies (JIT)</a></p>
  
  <p>a good way to preload all assemblies of an app. could be</p>
  
  <pre><code>Private Sub PreLoadJit()
    For Each type In Assembly.GetExecutingAssembly.GetTypes
      For Each method In type.GetMethods((BindingFlags.DeclaredOnly  _
                  Or (BindingFlags.NonPublic  _
                  Or (BindingFlags.Public  _
                  Or (BindingFlags.Instance Or BindingFlags.Static)))))
        If (((method.Attributes And MethodAttributes.Abstract)  _
                  = MethodAttributes.Abstract)  _
                  OrElse method.ContainsGenericParameters) Then
          continue For
        End If
        System.Runtime.CompilerServices.RuntimeHelpers.PrepareMethod(method.MethodHandle)
      Next
    Next
  End Sub
  </code></pre>
  
  <p>But when launch the method?
  I think could be the first method in the MyBase.Load Method, but don't know if i'm right.</p>
  
  <p>And following this older article</p>
  
  <p><a href="https://www.codeproject.com/Articles/31316/Pre-compile-pre-JIT-your-assembly-on-the-fly-or-tr" rel="nofollow noreferrer">https://www.codeproject.com/Articles/31316/Pre-compile-pre-JIT-your-assembly-on-the-fly-or-tr</a> </p>
  
  <p>The author uses a thread to run the method.
  What about build pre-jit on starting as a method called in the mainthread, or lauch it in a separate thread?</p>