When I try an connect to an instance that does not exist the UI locks up in my application I have tried using a new thread but this does not seem to work
//call from main class
Dispatcher.BeginInvoke(new Action(
() => Timedtask(instance, database)));
//Method
public void Timedtask(string instance, string database)
{
Timer.Start();
Timer.Tick += delegate
{
if (!TimedTask.timer_Tick(instance, database))
{
Dispatcher.CurrentDispatcher.Invoke(Stopped);
}
};
}
// Try an open connection
using (var con1 = new SqlConnection
{
ConnectionString = @"Data Source=" + instanceName1 + ";Integrated Security=SSPI;" +
"MultipleActiveResultSets=true;"
})
{
//more code
con1.Open();
//more code
}