How to implement a Cancel button that will kill a Stored Procedure call?

Discussion of open issues, suggestions and bugs regarding ADO.NET provider for Oracle
Post Reply
stoyang
Posts: 2
Joined: Fri 19 Jan 2007 00:08

How to implement a Cancel button that will kill a Stored Procedure call?

Post by stoyang » Fri 19 Jan 2007 00:21

Hi,

I am trying to create a dialog box that executes a Stored Procedure using OraDirect and has a Cancel button allowing the user to cancel the operation. I am able to launch a new thread that is supposed to execute the stored procedure but my UI thread freezes. If I do anything else that is time consuming (such as a very big loop) in that new thread I am able to successfully push the Cancel button and kill it. However, as soon as I call executeNonQuery on a OracleCommand object the whole app freezes.

Help please,
Stoyan


// This is how I start the thread
public delegate void ProcessFunction();
public MessageWindow(ProcessFunction func)
{
InitializeComponent();
Thread thread = new Thread(new ThreadStart(func));
thread.Start();
}

// This is how I call the MessageWindow class
new MessageWindow(CreateBackup).ShowDialog(this);

// And this is the function that is supposed to make the SP call
public void CreateBackup()
{
/* doing something large as long as it is not SP call works
for (long i = 0; i < 10000000000; i++)
{
string t = "";
}*/

using (OracleCommand cmd = new OracleCommand("BackupManager.Backup", ConnectionManager.Instance.Connection))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.ExecuteNonQuery();
}
}

Alexey
Posts: 2756
Joined: Mon 13 Mar 2006 07:43

Post by Alexey » Fri 19 Jan 2007 07:06

Unfortunately, we cannot provide general advice on programmimg techniques because this topic is beyond the scope of our support program.

Post Reply