Click here to Skip to main content
15,921,793 members
Home / Discussions / Managed C++/CLI
   

Managed C++/CLI

 
GeneralRe: [Message Deleted] Pin
Russell'14-Sep-07 22:29
Russell'14-Sep-07 22:29 
Questionsetup project Pin
Franken10-Sep-07 9:15
Franken10-Sep-07 9:15 
QuestionHelp me about " template" Pin
ubriela10-Sep-07 5:26
ubriela10-Sep-07 5:26 
AnswerRe: Help me about " template" Pin
Mark Salsbery10-Sep-07 5:46
Mark Salsbery10-Sep-07 5:46 
QuestionRe: Help me about " template" Pin
Hamid_RT12-Sep-07 23:10
Hamid_RT12-Sep-07 23:10 
Questionusb otg??? Pin
kutalinelucas10-Sep-07 1:24
kutalinelucas10-Sep-07 1:24 
AnswerRe: usb otg??? Pin
Mark Salsbery10-Sep-07 5:49
Mark Salsbery10-Sep-07 5:49 
Questionredefinition error (Library) Pin
palanirajan10-Sep-07 0:03
palanirajan10-Sep-07 0:03 
AnswerRe: redefinition error (Library) Pin
Mark Salsbery10-Sep-07 5:51
Mark Salsbery10-Sep-07 5:51 
QuestionHelp with accessing COM component. Pin
art_ami9-Sep-07 19:28
art_ami9-Sep-07 19:28 
QuestionHelp with C program [modified] Pin
eitwoman8-Sep-07 13:21
eitwoman8-Sep-07 13:21 
AnswerRe: Help with C program Pin
Mark Salsbery9-Sep-07 7:54
Mark Salsbery9-Sep-07 7:54 
GeneralRe: Help with C program Pin
eitwoman10-Sep-07 1:59
eitwoman10-Sep-07 1:59 
AnswerRe: Help with C program Pin
Mark Salsbery10-Sep-07 6:53
Mark Salsbery10-Sep-07 6:53 
GeneralRe: Help with C program Pin
eitwoman10-Sep-07 10:00
eitwoman10-Sep-07 10:00 
QuestionArray and String Pin
pourang7-Sep-07 21:58
pourang7-Sep-07 21:58 
AnswerRe: Array and String Pin
ubriela7-Sep-07 23:00
ubriela7-Sep-07 23:00 
GeneralRe: Array and String Pin
George L. Jackson8-Sep-07 5:27
George L. Jackson8-Sep-07 5:27 
GeneralRe: Array and String Pin
pourang10-Sep-07 4:20
pourang10-Sep-07 4:20 
AnswerRe: Array and String Pin
George L. Jackson8-Sep-07 5:23
George L. Jackson8-Sep-07 5:23 
GeneralRe: Array and String Pin
pourang9-Sep-07 11:59
pourang9-Sep-07 11:59 
AnswerRe: Array and String Pin
Chetan Patel9-Sep-07 21:23
Chetan Patel9-Sep-07 21:23 
GeneralRe: Array and String Pin
pourang10-Sep-07 4:24
pourang10-Sep-07 4:24 
QuestionPrinting from Print-Preview results in different output Pin
BuckBrown7-Sep-07 10:37
BuckBrown7-Sep-07 10:37 
QuestionHelp with Threading Pin
art_ami7-Sep-07 3:14
art_ami7-Sep-07 3:14 
Here is the code snippet of my application. background thread is a managed thread.

Code Snippet

public ref class Form1 : public System::Windows::Forms::Form

{

private:

Thread^ myThread; //Managed Thread Handle

IDiscovery* discObj // Pointer to unmanaged type

public :

static System::Void ThreadProc(System::Object^ pv)

{

System::IntPtr^ ptrDiscovery = cli::safe_cast<system::intptr^>(pv);

IDiscovery *discObj;

discObj = (IDiscovery *)ptrDiscovery->ToPointer();

//get the list from IDiscovery

discObj->discoverList(false);

}//END OF THREADPROC



private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e)

{

System::IntPtr^ pV = gcnew System::IntPtr(static_cast<void*>(discObj));

myThread = gcnew Thread(gcnew ParameterizedThreadStart(Form1::ThreadProc));

myThread->Start(pV);



}//END OF FUNCTION


At times I am getting following exception:

An unhandled exception of type 'System.AccessViolationException'

Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.


I am not sure whether this the right way to do it. Please suggest.



Thanks a lot,

Arti

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.