|
|
The thing that confuses me is that &m_pFormatContext should be an unmanaged pointer, therefore AFAIU shouldn't need pinning?
|
|
|
|
|
Your unmanaged pointer is inside a managed object. You need pin_ptr to prevent the unmanaged pointer pointing to different location during the garbage collection.
Have you tried changing to pin_ptr? I believe that should solve the issue.
|
|
|
|
|
I had a similar issue. I read that you have to create the pointer locally in the function then assign it to a member variable afterwards
something like this:
IDiscMaster *dscMaster;
hResult = CoCreateInstance(CLSID_MSDiscMasterObj, 0, CLSCTX_ALL, IID_IDiscMaster, &dscMaster);
if (SUCCEEDED(hResult))
m_pDiscMaster = (IDiscMaster *)dscMaster;
else
return false;
Don't be overcome by evil, but overcome evil with good
|
|
|
|
|
Hey when I abort a thread it throws a ThreadAbortException right?
I catch it, it is re thrown again but the first time I catch it I call the function ResetAbort(), but the thread still aborts
Help please...
Here's my code
#include "stdafx.h"
using namespace System;
using namespace System::Threading;
ref class MyThread
{
public:
static void ThreadFunc(Object ^Name);
};
void MyThread::ThreadFunc(Object ^Name)
{
Thread ^thr = Thread::CurrentThread;
try
{
for (int i = 0; i < 100; i++)
{
Console::WriteLine("{0} {1}", Name, i.ToString());
Thread::Sleep(10);
}
return;
}
catch (ThreadAbortException^)
{
Console::WriteLine("{0} Aborted", Name);
thr->ResetAbort();
}
}
void main()
{
Console::WriteLine("Main Program Starts");
Thread ^thr1 = gcnew Thread(gcnew ParameterizedThreadStart(&MyThread::ThreadFunc));
Thread ^thr2 = gcnew Thread(gcnew ParameterizedThreadStart(&MyThread::ThreadFunc));
thr1->Start("Thread1");
thr2->Start("Thread2");
Thread::Sleep(20);
thr1->Abort();
Thread::Sleep(40);
thr2->Abort();
Console::WriteLine("Main Program Ends");
}
|
|
|
|
|
I changed like
void MyThread::ThreadFunc(Object ^Name)
{
for (int i = 0; i < 100; i++)
{
Thread ^thr = Thread::CurrentThread;
try
{
Console::WriteLine("{0} {1}", Name, i.ToString());
Thread::Sleep(10);
}
catch (ThreadAbortException^ ex)
{
Console::WriteLine("{0} Aborted", Name);
thr->ResetAbort();
}
}
} You can find out the reason yourself
modified on Monday, January 12, 2009 8:36 AM
|
|
|
|
|
Why you put it into a loop?
|
|
|
|
|
Following is your code
Thread ^thr = Thread::CurrentThread;
try
{
for (int i = 0; i < 100; i++)
{
Console::WriteLine("{0} {1}", Name, i.ToString());
Thread::Sleep(10);
}
return;
}
catch (ThreadAbortException^)
{
Console::WriteLine("{0} Aborted", Name);
thr->ResetAbort();
} In this, when the thread abort exception is raised, the control will come out of the loop and enter into the catch block. Thread.ResetAbort puts the thread again in running state, but since the loop is finished, there is nothing to execute and the thread will return immediately. This is the reason why your code failed.
|
|
|
|
|
So when an exception is caught, doesn't it return backs to the try block?
|
|
|
|
|
No. After the ResetAbort call, control will come out of catch and execute the next statements. It will not go back to the try .
|
|
|
|
|
Hi~all.
I am using visual 2008 c++ to undergo a project with the window form, my supervisor said that I should embed a 3D animation ,it only need to include a sun, a solar panel and a house in it,my case is that there are some buttons for the user to input the value. When the position of the panel change,the panel in the animation will also change,and for the sun and house ,the sun is just need to move from east to west to simulate a whole day situation.But i don't know whether and how to do it with c++..
Actually i have tried the Dark GDK, but it seems that I need to open another project if i use it and I am not very familiar with it....
Can anyone suggest how I can solve it...thanks..
|
|
|
|
|
My application has UI in C#, and buisness logic in MFC/VC++. The connection between Managed and unmanaged code are provided using ManagedC++. Now I want the events raised from my VC++ class, to be handled or received in ManagedC++ layer.
The question is it possible to do it. If so any reference article/code with be helpful.
Thanks in Advance!
|
|
|
|
|
Hello. Hope all will be fine here.
I am working in .Net 2005. My project is developing a messenger using VC++. All the work has been done almost. What I need more is here:
I have to include web iframe such that:
1. the client wants an web iframe at the bottom of the messenger with a static link to a website.
2: The iframe contains static info and banners.
2: Also if the client is started there should be opened a browser at the backend like a popup.
can anybody give me idea or any helping web link.
Thanks
Azhar Rahi
|
|
|
|
|
use explorer control and assisgn any link to it
|
|
|
|
|
actually one thing I missed. My VC++ code is unmannaged. So how can I do that then ?
I think may be problem is something else?
Azhar Rahi
modified on Sunday, January 11, 2009 4:14 PM
|
|
|
|
|
Hi guys,
I been working on a antivirus project as my final year project.. i have some problem with getting the list of all the files in a directory..
Lets say i choose C:/ and i want the list of all the files in the directory. Kindly help me with this ya... its a console program and i using DavC++ compiler...
Regards,
Thilek
|
|
|
|
|
This is the C++/CLI (Manage C++) forum. You need to ask your question in the C++ / MFC forum.
"We make a living by what we get, we make a life by what we give." --Winston Churchill
|
|
|
|
|
I want to Invoke a Web Service using Visual C++ .NET. Please provide me with information.
I have sample code to invoke web service using c#. The web service method has complex data as input. Please reply.
|
|
|
|
|
If you have sample code, why not convert it to C++/CLI?
Or just use C#?
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Here[^] and here[^] as well, pick a forum and stick to it!!!
|
|
|
|
|
ok.fine. Tell me how to invoke web service using managed c++ (in .NET 2003/2005)
|
|
|
|
|
Hello everyone, I'm relatively new to writing code in C++ and I've been running into a problem. You see, I got a chunk of code off the internet for use in my program and it includes:
using namespace System
But the compiler doesn't like it. From what I can tell it isn't declared in the body of the code and it sounds rather like a predefined namespace. Is there something I need to include to fix this or what? Thanks in advance
|
|
|
|
|
linkfitz wrote: But the compiler doesn't like it.
How do you know this? It would be helpful to see the EXACT error message
(or a transcript of the conversation you had with the compiler if it was verbal).
The System namespace is part of the .NET framework so to start with you'll need
to compile the code for C++/CLI. Then at the very minimum, your project will need a
reference to the .NET framework System DLL.
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
hey i'm building a drawing app (actually from book) and now I want it to don't flicker, everytime i draw something or move mouse (for highlighting drawings) it need to be redrawn. So how to lessen the flickering?
Can this be gone with multithreading?
modified on Tuesday, January 6, 2009 10:09 AM
|
|
|
|
|
Multithreading probably won't help flickering since generally UI operations
have to be done on the same thread.
One way to minimize flickering is to only redraw an area that changes.
A better way to eliminate flickering is to use double buffering -
do your drawing to memory and then render the finished drawing to the screen.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|