Aborting updates in a DataTable
-
I am having a problem with aborting updates in a DataTable. I am hooked into the RowChanging Event and, as the docs say, throwing an exception to cause the update to abort. My problem is that the DataSet does not catch this exception and it bubbles all the way up to Main() which is a bit to late to do anything with. For this example I have a single form with a ListBox and a TextBox bound to a strongly typed DataSet. Anyone know how to handle this situation Thanks Sttephen.
-
I am having a problem with aborting updates in a DataTable. I am hooked into the RowChanging Event and, as the docs say, throwing an exception to cause the update to abort. My problem is that the DataSet does not catch this exception and it bubbles all the way up to Main() which is a bit to late to do anything with. For this example I have a single form with a ListBox and a TextBox bound to a strongly typed DataSet. Anyone know how to handle this situation Thanks Sttephen.
could you try butting your listbox on a seperate thread and abort the thread ? or maybe try putting the update in a while statement with a bool.... ie. it would be a pain too do it with the while statement though cause it would stay in it until the update tells it not too. i would try threads. while(turnOffUpdateflag==false) { ;//do my update } while(myThread.IsAlive == true) { ;//do update }
-
could you try butting your listbox on a seperate thread and abort the thread ? or maybe try putting the update in a while statement with a bool.... ie. it would be a pain too do it with the while statement though cause it would stay in it until the update tells it not too. i would try threads. while(turnOffUpdateflag==false) { ;//do my update } while(myThread.IsAlive == true) { ;//do update }
There as to be a better way! I am trying to validate the row when the list changes to a different row. This triggers the RowChanging event from the dataset. If I create the ListBox on another thread, when I abort the thread, surely I would lose the list box as well, and would have to recreate it and restore it to it's current state. 15 minute project has now managed to waste the best part of a day!! This looked so simple when I read the docs. LOL, should have known better by now! ;-) Stephen.
-
There as to be a better way! I am trying to validate the row when the list changes to a different row. This triggers the RowChanging event from the dataset. If I create the ListBox on another thread, when I abort the thread, surely I would lose the list box as well, and would have to recreate it and restore it to it's current state. 15 minute project has now managed to waste the best part of a day!! This looked so simple when I read the docs. LOL, should have known better by now! ;-) Stephen.
i have a encryption program with the encryption method....the recursive file search method..all running on a string... when the user clicks stop..... it cancels the threads ..and the results that were found before the thread stopped are still in the list box... then when the user clicks the search button agian i tell the program too recreated the thread agian and it startes over any time you abort a thread you have to reintialize it ie make a private void just for your threads so you can call on then and get them reintialized when ever needed. i have never used a datagrid before (isnt that what you are using? cant remeber) but this has always worked for listboxes atleast. private void mylistboxThread() { Thread Update = new Thread(new ThreadStart(updatefunctions)) } private void updateFunctions() { //put your update code here. } Update.Start();//start thread Update.Abort();//abort thread jesse m :)
-
i have a encryption program with the encryption method....the recursive file search method..all running on a string... when the user clicks stop..... it cancels the threads ..and the results that were found before the thread stopped are still in the list box... then when the user clicks the search button agian i tell the program too recreated the thread agian and it startes over any time you abort a thread you have to reintialize it ie make a private void just for your threads so you can call on then and get them reintialized when ever needed. i have never used a datagrid before (isnt that what you are using? cant remeber) but this has always worked for listboxes atleast. private void mylistboxThread() { Thread Update = new Thread(new ThreadStart(updatefunctions)) } private void updateFunctions() { //put your update code here. } Update.Start();//start thread Update.Abort();//abort thread jesse m :)
But you are in control of starting the thread. What I want to do is in response to a users click on the listbox, which will be triggered from an incoming windows message (WM_MOUSE_DOWN or what ever) via the forms message loop that is running on the forms main thread, therefor my thread of execution would never make it onto my thread. Make sense? Stephen.