Here is what you do, in pseudo code, I don't remember exact syntax
private Event InsertCompleted
sub ThisSubDoesInsert()
' insert here . . . .
Raise Event InsertCompleted
end sub
Sub ThisSubOpensModal()
using f as new MyForm(ThisSubDoesInsert) ' may need AdressOf(...)
AddHandler Me.InsertCompleted, AddressOf f.SubThatWillCloseForm
f.ShowModal()
RemoveHandler Me.InsertCompleted, AddressOf f.SubThatWillCloseForm
End using
End sub
And in form
class MyForm
private _callback AS Action ' - set this in constructor
sub Form_Load
Me.Show()
_callback() ' This will call insert
end sub
sub SubThatWillCloseForm()
Me.Close()
end sub
End Class
In this code, you call a method that pops up the modal form while passing a callback to do insert once modal is open. When insert completes, the event is fired. This event is wired to a form method that will close the form. This is pseudo code, you need to make it real. No need for multi-threading here.