Click here to Skip to main content
15,885,244 members
Home / Discussions / C#
   

C#

 
GeneralRe: Non-XML ini-file supporting arrays, in plain text format? Pin
arnold_w19-Jun-14 21:47
arnold_w19-Jun-14 21:47 
GeneralRe: Non-XML ini-file supporting arrays, in plain text format? Pin
V.19-Jun-14 21:48
professionalV.19-Jun-14 21:48 
GeneralRe: Non-XML ini-file supporting arrays, in plain text format? Pin
Dave Kreskowiak20-Jun-14 1:48
mveDave Kreskowiak20-Jun-14 1:48 
Question"One or more exceptions" occurred at Task.Start() Pin
Sharath C V19-Jun-14 3:23
professionalSharath C V19-Jun-14 3:23 
AnswerRe: "One or more exceptions" occurred at Task.Start() Pin
OriginalGriff19-Jun-14 3:55
mveOriginalGriff19-Jun-14 3:55 
SuggestionRe: "One or more exceptions" occurred at Task.Start() Pin
Richard Deeming19-Jun-14 4:07
mveRichard Deeming19-Jun-14 4:07 
GeneralRe: "One or more exceptions" occurred at Task.Start() Pin
OriginalGriff19-Jun-14 4:15
mveOriginalGriff19-Jun-14 4:15 
AnswerRe: "One or more exceptions" occurred at Task.Start() Pin
Sharath C V19-Jun-14 21:18
professionalSharath C V19-Jun-14 21:18 
Thanks to both of you for your valuable help. Changed it as shown below and got it working without loosing sequence and with corresponding thread id...

private void TaskRunButton_Click(object sender, EventArgs e)
{
	// clear the list before writing
	listBox.Items.Clear();
	Task demoTask = new Task(DemoTask);
	demoTask.Start();
}

private void DemoTask()
{
	try
	{
		List<Task> tsk1 = new List<Task>();
		List<Task> tsk2 = new List<Task>();

		for (int i = 0; i < 10; i++)
		{
			tsk1.Add(new Task(TaskDemoWait100ms));
			tsk2.Add(new Task(TaskDemoWaitWait200ms));
		}

		for (int i = 0; i < 10; i++)
		{
			tsk1[i].Start();
			tsk2[i].Start();
			tsk2[i].Wait();
			listBox.BeginInvoke(new separatorDelegate(() =>
			{ listBox.Items.Add("------------"); }));
		}
	}
	catch (Exception ex)
	{
		string msg = ex.Message;
	}
}

delegate void taskdelegate(int threadId);
delegate void separatorDelegate();

private void TaskDemoWait100ms()
{
	Thread.Sleep(100);
	object[] param = new object[1];

	param[0] = (object)Thread.CurrentThread.ManagedThreadId;

	listBox.BeginInvoke(new taskdelegate((int threadId) =>
	{ listBox.Items.Add("Wait 100 ms, Thread Id = " + threadId); }), param);
}

private void TaskDemoWaitWait200ms()
{
	Thread.Sleep(200);
	object[] param = new object[1];

	param[0] = (object)Thread.CurrentThread.ManagedThreadId;

	listBox.BeginInvoke(new taskdelegate((int threadId) =>
	{ listBox.Items.Add("Wait 200 ms, Thread Id = " + threadId); }), param);
}

GeneralRe: "One or more exceptions" occurred at Task.Start() Pin
Sharath C V19-Jun-14 19:10
professionalSharath C V19-Jun-14 19:10 
AnswerRe: "One or more exceptions" occurred at Task.Start() Pin
Richard Deeming19-Jun-14 4:06
mveRichard Deeming19-Jun-14 4:06 
GeneralRe: "One or more exceptions" occurred at Task.Start() Pin
Sharath C V19-Jun-14 20:02
professionalSharath C V19-Jun-14 20:02 
QuestionSendkeys to excel without open workbook - C# Pin
bonjot19-Jun-14 1:26
bonjot19-Jun-14 1:26 
AnswerRe: Sendkeys to excel without open workbook - C# Pin
Pete O'Hanlon19-Jun-14 2:11
mvePete O'Hanlon19-Jun-14 2:11 
GeneralRe: Sendkeys to excel without open workbook - C# Pin
bonjot19-Jun-14 2:27
bonjot19-Jun-14 2:27 
AnswerRe: Sendkeys to excel without open workbook - C# Pin
Dave Kreskowiak19-Jun-14 2:11
mveDave Kreskowiak19-Jun-14 2:11 
GeneralRe: Sendkeys to excel without open workbook - C# Pin
bonjot19-Jun-14 2:29
bonjot19-Jun-14 2:29 
QuestionC# FOR Loop Speed Issue Pin
exfosys18-Jun-14 21:02
exfosys18-Jun-14 21:02 
AnswerRe: C# FOR Loop Speed Issue Pin
Pete O'Hanlon18-Jun-14 21:18
mvePete O'Hanlon18-Jun-14 21:18 
AnswerRe: C# FOR Loop Speed Issue Pin
OriginalGriff18-Jun-14 21:51
mveOriginalGriff18-Jun-14 21:51 
GeneralRe: C# FOR Loop Speed Issue Pin
exfosys18-Jun-14 22:41
exfosys18-Jun-14 22:41 
GeneralRe: C# FOR Loop Speed Issue Pin
OriginalGriff18-Jun-14 23:12
mveOriginalGriff18-Jun-14 23:12 
AnswerRe: C# FOR Loop Speed Issue Pin
Mycroft Holmes18-Jun-14 22:31
professionalMycroft Holmes18-Jun-14 22:31 
GeneralRe: C# FOR Loop Speed Issue Pin
exfosys18-Jun-14 22:42
exfosys18-Jun-14 22:42 
GeneralRe: C# FOR Loop Speed Issue Pin
Mycroft Holmes18-Jun-14 22:54
professionalMycroft Holmes18-Jun-14 22:54 
GeneralRe: C# FOR Loop Speed Issue Pin
exfosys18-Jun-14 23:50
exfosys18-Jun-14 23:50 

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.