Click here to Skip to main content
15,888,733 members
Home / Discussions / C#
   

C#

 
AnswerRe: separate compound color planes Pin
Pete O'Hanlon14-Nov-13 19:36
mvePete O'Hanlon14-Nov-13 19:36 
GeneralRe: separate compound color planes Pin
harold aptroot14-Nov-13 21:14
harold aptroot14-Nov-13 21:14 
GeneralRe: separate compound color planes Pin
nhocclever17-Nov-13 16:06
nhocclever17-Nov-13 16:06 
GeneralRe: separate compound color planes Pin
harold aptroot17-Nov-13 21:06
harold aptroot17-Nov-13 21:06 
GeneralRe: separate compound color planes Pin
nhocclever18-Nov-13 23:53
nhocclever18-Nov-13 23:53 
QuestionC# modify ssrs report property Pin
dcof14-Nov-13 10:41
dcof14-Nov-13 10:41 
QuestionConvert HTML to PDF Pin
NYCABR14-Nov-13 8:50
NYCABR14-Nov-13 8:50 
QuestionThreading - Play / pause / stop question Pin
Mirko Jurcevic14-Nov-13 2:07
Mirko Jurcevic14-Nov-13 2:07 
This is copy of my comment on A Multi-threading Example.

I'm beginner so I have question if anyone can help me.
I've used part of threading code, I have button that should stop the process, but, as you can see in the code below, I have 3 nested loops, and operation in topmost loop (which I've put into thread) takes some time to do the work, and my stop button is not very responsive.
When I put thread sleep to 3 seconds, button is responsive, but that makes topmost loop even slower (by that 3 second per iteration).
What should be simple start stop operation now became much more than I can handle. Confused | :confused:

I have this code so far:
C#
private void btnCaptureScreen_Click(object sender, EventArgs e) {
  if (LIST_CheckedTreeNodes.Count > 0) {
     btnCaptureScreen.Enabled = false; /*button that runs this operation*/
     btnSTOP.Enabled = true;  /*Stop button for stopping operation*/
     abort_process = false;   /*global variable I tried to use for breaking out of loops*/
	
     thread = new Thread(delegate() {
          foreach (iTreeNode node in LIST_CheckedTreeNodes) {
	       if (abort_process) break;

	       this.BeginInvoke((ThreadStart)delegate() {
	            CaptureScreenFromNode(node);
	       });

	       if (abort_process) break;
	  }
	
          /*after thread is done, restore everything to normal state*/				
	  this.BeginInvoke((ThreadStart)delegate() {
		btnCaptureScreen.Enabled = true;
		btnSTOP.Enabled = false;		
	  });
	  Thread.Sleep(10);
     });
     thread.Start();
  }
}


CaptureScreenFromNode(node) code:
C#
private void CaptureScreenFromNode(iTreeNode node) {
     treeView.SelectedNode = node;
     
/*** Node property information ***/
     string nodePI = node.GetType().GetProperty("iDiagramType").GetValue(node).ToString();
           foreach (iComboBox combo in LIST_COMBOX_SelectedLoadCases) {
		if (abort_process) break;
                Check_Selected_Load_Cases(combo);
                /*** Combobox property information ***/
		string comboPI = combo.GetType().GetProperty("iDiagramType").GetValue(combo).ToString();
/*** Loop has found appropriate combobox with selected load cases ***/
		if (comboPI == nodePI) {
			if (combo.Items.Count > 0) {
				for (int j = 0; j < combo.Items.Count; j++) {
				     if (abort_process) break;
				     /*** DO SOME WORK ***/
				}
			}
			else {
                             /*** DO SOME OTHER WORK ***/}
			}
		}
	} /*end of foreach*/
}


Please help Sigh | :sigh:
AnswerRe: Threading - Play / pause / stop question Pin
Pete O'Hanlon14-Nov-13 2:28
mvePete O'Hanlon14-Nov-13 2:28 
GeneralRe: Threading - Play / pause / stop question Pin
Mirko Jurcevic14-Nov-13 2:33
Mirko Jurcevic14-Nov-13 2:33 
GeneralRe: Threading - Play / pause / stop question Pin
Pete O'Hanlon14-Nov-13 3:02
mvePete O'Hanlon14-Nov-13 3:02 
AnswerRe: Threading - Play / pause / stop question Pin
Ennis Ray Lynch, Jr.14-Nov-13 5:41
Ennis Ray Lynch, Jr.14-Nov-13 5:41 
QuestionConvert Datatable data into Json data in C# Pin
susanna.floora14-Nov-13 1:12
susanna.floora14-Nov-13 1:12 
AnswerRe: Convert Datatable data into Json data in C# Pin
V.14-Nov-13 2:04
professionalV.14-Nov-13 2:04 
AnswerRe: Convert Datatable data into Json data in C# Pin
Richard Deeming14-Nov-13 4:19
mveRichard Deeming14-Nov-13 4:19 
Question[Solved] Windows Service - problem with write file at scheduled time Pin
emma.sun.sts13-Nov-13 20:06
emma.sun.sts13-Nov-13 20:06 
AnswerRe: Windows Service - problem with write file at scheduled time Pin
Bernhard Hiller13-Nov-13 20:56
Bernhard Hiller13-Nov-13 20:56 
GeneralRe: Windows Service - problem with write file at scheduled time Pin
emma.sun.sts13-Nov-13 21:25
emma.sun.sts13-Nov-13 21:25 
GeneralRe: Windows Service - problem with write file at scheduled time Pin
Bernhard Hiller13-Nov-13 21:29
Bernhard Hiller13-Nov-13 21:29 
GeneralRe: Windows Service - problem with write file at scheduled time Pin
emma.sun.sts13-Nov-13 21:39
emma.sun.sts13-Nov-13 21:39 
GeneralRe: Windows Service - problem with write file at scheduled time Pin
Eddy Vluggen13-Nov-13 21:48
professionalEddy Vluggen13-Nov-13 21:48 
GeneralRe: Windows Service - problem with write file at scheduled time Pin
Pete O'Hanlon14-Nov-13 0:14
mvePete O'Hanlon14-Nov-13 0:14 
Questionread only Pin
seeker6213-Nov-13 8:41
seeker6213-Nov-13 8:41 
SuggestionRe: read only Pin
Richard MacCutchan13-Nov-13 8:56
mveRichard MacCutchan13-Nov-13 8:56 
GeneralRe: read only Pin
seeker6213-Nov-13 9:13
seeker6213-Nov-13 9:13 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.