The question and the code do not seem to make any sense.
Three nested loop do nothing, but the should not be executed in the UI thread, as the execution may take some time. You should never execute in a UI thread anything which contains blocking calls of just take extended period of time.
From the other hand,
should not be called in a separate thread. First of all, it cannot work, because you cannot call any methods or properties of currently running UI from any thread except the UI thread where the currently running
instance is executed. You can only work with UI indirectly, via the invocation.
This is explained in my past answers:
Control.Invoke() vs. Control.BeginInvoke()
Problem with Treeview Scanner And MD5
More importantly, you never need to run the method
from a separate thread. This method should be called directly from the UI thread. The method creates and shows the form and returns immediately.