Hello out there,
is there any possibility for me to catch or avoid crashes caused within
unmanaged code?
The situation:
I'm writing a managed wrapper in MC++, and in there I use some
unmanaged COM methods for creating thumbnails.
The problem: One special line may cause a crash, and subsequently
blocks my whole application.
The line looks like this:
// unmanaged:
IExtractImage * peiURL = NULL; // use shell interface
HR_TRY(hr = peiURL->Extract(pThumbnail)); // application hangs in
this line sometimes
So is there any way for me to avoid blocking the whole app?
Normal exception-handling won't do since this com-method doesn't throw
any exceptions.
Maybe I could call this function in a separate thread, and if it
doesn't respond within a certain time I should kill the thread
programatically?
Are there other ways out there?
Thanks in advance,
TheLetti 3 1387
Extracting thumbnails from a background thread is a good solution from the
performance point of view as well. Thumbnail extraction can be quite slow
for some items.
- Atul
Sky Software http://www.ssware.com/
Drop-In Windows Explorer-Like Shell Browsing UI for your apps.
"TheLetti" <th************@gmx.net> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com... Hello out there,
is there any possibility for me to catch or avoid crashes caused within unmanaged code?
The situation: I'm writing a managed wrapper in MC++, and in there I use some unmanaged COM methods for creating thumbnails.
The problem: One special line may cause a crash, and subsequently blocks my whole application.
The line looks like this:
// unmanaged: IExtractImage * peiURL = NULL; // use shell interface HR_TRY(hr = peiURL->Extract(pThumbnail)); // application hangs in this line sometimes
So is there any way for me to avoid blocking the whole app? Normal exception-handling won't do since this com-method doesn't throw any exceptions. Maybe I could call this function in a separate thread, and if it doesn't respond within a certain time I should kill the thread programatically? Are there other ways out there?
Thanks in advance,
TheLetti
Hi Atul,
thank you for your suggestions. Indeed, I have already tried executing
this thumbnail code within a separate thread, and this works now for
me!
greez,
TheLetti
Hi again,
while implementing thumbnail extraction within a seperate thread, I
encountered another problem:
I'm using the System::Threading::Thread class to put my code into a
thread.
After starting the thread, which extracts the thumbnail actually, I
call myThread->Join(timeout)
This method returns either if the thread has terminated successfully,
or after a specified timeout.
In case of the timeout the thread hangs in my unmanaged code, and so
the thread stays alive.
All I want to do now is to terminate this stubborn thread.
Unfortunately, calling myThread->Abort() doesn't do the trick, because
it hangs in unmanaged code.
The documentation says this:
"If a thread makes an unmanaged call into the operating system that has
blocked the thread in unmanaged code, the runtime will not take control
of it for System.Threading.Thread.Interrupt or
System.Threading.Thread.Abort. In the case of
System.Threading.Thread.Abort, the runtime marks the thread for Abort
and takes control of it when it re-enters managed code."
So the thread couldn't be aborted, because it never returns to managed
code again.
My question now is, if there is ANY possibility to terminate the thread
anyways?
thx in advance,
TheLetti This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Neil |
last post by:
I am developing a demo in C# using Managed DirectX. I wanted to use a
C++ static library in the demo (its a class for handling physics), so
I decided to create my Graphics classes in C#, inherit...
|
by: Niall |
last post by:
I'm attempting to put a C# front end on my unmanaged C++ ray tracer code.
It's still in experimental stage, as I have never done anything with
exporting types from an unmanaged dll through to a...
|
by: Mark Ingram |
last post by:
Hi,
how can i return an array of strings from an unmanaged c++ dll into a c#
application?
cheers
Mark
|
by: Eric Twietmeyer |
last post by:
Hello,
Am I mistaken in thinking that if I have a mc++ dll that I should be able to
link against it (so long as it has exported symbols via declspec(dllexport))
in an unmanaged application?
I...
|
by: Vasco Lohrenscheit |
last post by:
Hi,
I have a Problem with unmanaged exception. In the debug build it works
fine to catch unmanaged c++ exceptions from other dlls with
//managed code:
try
{
//the form loads unmanaged dlls...
|
by: Tommy Svensson \(InfoGrafix\) |
last post by:
I've been instructed to work againt a huge unmanaged C++ API from a C#
application.
Now, the only way, as I've understood it, is to go the Managed Extensions
for C++ way. This means I have to...
|
by: Maxwell |
last post by:
Hello,
Newbie question here for disposing of unmanaged resources in MC++.NET.
I have a managed VS.NET 2003 MC++ wrapper class that wraps a unmanaged
C++ dll. What I am trying to figure out is...
|
by: MC-Advantica |
last post by:
Does anyone have a simple "Hello World" like application that demonstrates
unmanaged C++ calling managed C++ developed in VS2005? I'm confused by many
posts as they discuss managed extensions from...
|
by: DaTurk |
last post by:
Hi,
I have a rather interesting problem. I have a unmanged c++ class
which needs to communicate information to managed c++ via callbacks,
with a layer of c# on top of the managed c++ ultimatley...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
| |