Click here to Skip to main content
15,893,588 members
Home / Discussions / C#
   

C#

 
GeneralRe: Using mshtml to parse a html document in C# works very slow - Why ? Pin
DimaC30-Dec-05 7:16
DimaC30-Dec-05 7:16 
GeneralRe: Using mshtml to parse a html document in C# works very slow - Why ? Pin
DimaC29-Dec-05 11:55
DimaC29-Dec-05 11:55 
QuestionMS Outllok Database Connection Pin
ArjoGupta29-Dec-05 2:08
ArjoGupta29-Dec-05 2:08 
AnswerRe: MS Outllok Database Connection Pin
Judah Gabriel Himango29-Dec-05 4:45
sponsorJudah Gabriel Himango29-Dec-05 4:45 
Questionhelp in creating a xml Pin
dhol29-Dec-05 1:53
dhol29-Dec-05 1:53 
AnswerRe: help in creating a xml Pin
Judah Gabriel Himango29-Dec-05 4:42
sponsorJudah Gabriel Himango29-Dec-05 4:42 
GeneralRe: help in creating a xml Pin
dhol3-Jan-06 0:46
dhol3-Jan-06 0:46 
QuestionAborting a thead in ThreadPool Pin
munshisoft29-Dec-05 0:49
munshisoft29-Dec-05 0:49 
Hi,
I am planning to use this approach please let me know if there is a problem in this approach..
Same code can be written for C# as well..

Thanks and Best Regards,
Shahid

// This example shows how to create an Object* containing task
// information, and pass that Object* to a task queued for
// execution by the thread pool.
#include "stdafx.h"
#using

using namespace System;
using namespace System::Threading;

// TaskInfo holds state information for a task that will be
// executed by a ThreadPool thread.
public __gc class TaskInfo
{
// State information for the task. These members
// can be implemented as read-only properties, read/write
// properties with validation, and so on, as required.
public:
String* Boilerplate;
int Value;
Thread *tHandle;

// Public constructor provides an easy way to supply all
// the information needed for the task.
TaskInfo(String* text, int number)
{
Boilerplate = text;
Value = number;
tHandle=NULL;
}
};

public __gc struct Example
{
// The thread procedure performs the independent task, in this case
// formatting and printing a very simple report.
//
static void ThreadProc(Object* stateInfo)
{
try
{

//Do Always
TaskInfo *tInfo= (TaskInfo *)(stateInfo);
tInfo->tHandle = Thread::CurrentThread;

TaskInfo* ti = dynamic_cast(stateInfo);
Thread::Sleep(10000);
Console::WriteLine(ti->Boilerplate, __box(ti->Value));
}
catch(ThreadAbortException *Te)
{
Console::WriteLine(S"Thread Aborted by Main Thread{0}",Te->ToString());
}
}
};

int main()
{
try
{// Create an object containing the information needed
// for the task.
TaskInfo* ti = new TaskInfo(S"This report displays the number {0}.", 42);

// Queue the task and data.
if (ThreadPool::QueueUserWorkItem(new WaitCallback(0, Example::ThreadProc), ti))
{
Console::WriteLine(S"Main thread does some work, then sleeps.");

// If you comment out the Sleep, the main thread exits before
// the ThreadPool task has a chance to run. ThreadPool uses
// background threads, which do not keep the application
// running. (This is a simple example of a race condition.)
Thread::Sleep(1000);

//Abort the Thread started
ti->tHandle->Abort();

Thread::Sleep(15000);
Console::WriteLine(S"Main thread exits.");


}
else
{
Console::WriteLine(S"Unable to queue ThreadPool request.");
}
}
catch (...)
{
Console::WriteLine(S"Unknown Exception Occured in Main");
}
return 0;
}
;

AnswerRe: Aborting a thead in ThreadPool Pin
S. Senthil Kumar29-Dec-05 2:42
S. Senthil Kumar29-Dec-05 2:42 
QuestionTo implement password rememberance in Windows application? Pin
MudkiSekhon28-Dec-05 23:40
MudkiSekhon28-Dec-05 23:40 
AnswerRe: To implement password rememberance in Windows application? Pin
Judah Gabriel Himango29-Dec-05 4:25
sponsorJudah Gabriel Himango29-Dec-05 4:25 
GeneralRe: To implement password rememberance in Windows application? Pin
MudkiSekhon29-Dec-05 20:57
MudkiSekhon29-Dec-05 20:57 
GeneralRe: To implement password rememberance in Windows application? Pin
Judah Gabriel Himango30-Dec-05 4:36
sponsorJudah Gabriel Himango30-Dec-05 4:36 
QuestionProblem in selected row after sorting in datagridview Pin
Mertli Ozgur Nevres28-Dec-05 23:01
Mertli Ozgur Nevres28-Dec-05 23:01 
AnswerRe: Problem in selected row after sorting in datagridview Pin
Judah Gabriel Himango29-Dec-05 4:27
sponsorJudah Gabriel Himango29-Dec-05 4:27 
GeneralRe: Problem in selected row after sorting in datagridview Pin
Mertli Ozgur Nevres30-Dec-05 4:02
Mertli Ozgur Nevres30-Dec-05 4:02 
GeneralRe: Problem in selected row after sorting in datagridview Pin
Judah Gabriel Himango30-Dec-05 4:31
sponsorJudah Gabriel Himango30-Dec-05 4:31 
QuestionFlickering during customized resizing of the form Pin
Saanya28-Dec-05 21:00
Saanya28-Dec-05 21:00 
AnswerRe: Flickering during customized resizing of the form Pin
Judah Gabriel Himango29-Dec-05 4:55
sponsorJudah Gabriel Himango29-Dec-05 4:55 
QuestionActive Directory Connection Pin
HolyGrandFather28-Dec-05 20:33
HolyGrandFather28-Dec-05 20:33 
AnswerRe: Active Directory Connection Pin
Judah Gabriel Himango29-Dec-05 4:29
sponsorJudah Gabriel Himango29-Dec-05 4:29 
QuestionCould someone please explain currencyManager to me Pin
kourvoisier28-Dec-05 20:22
kourvoisier28-Dec-05 20:22 
AnswerRe: Could someone please explain currencyManager to me Pin
Judah Gabriel Himango29-Dec-05 4:35
sponsorJudah Gabriel Himango29-Dec-05 4:35 
GeneralRe: Could someone please explain currencyManager to me Pin
kourvoisier29-Dec-05 5:11
kourvoisier29-Dec-05 5:11 
QuestionRegarding Setting Registry Value Pin
A.Grover28-Dec-05 20:21
A.Grover28-Dec-05 20:21 

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.