473,698 Members | 2,392 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Catching unmanaged crashes in MC++

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(pThumb nail)); // 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

Nov 17 '05 #1
3 1408
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.goo glegroups.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(pThumb nail)); // 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

Nov 17 '05 #2
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

Nov 17 '05 #3
Hi again,

while implementing thumbnail extraction within a seperate thread, I
encountered another problem:

I'm using the System::Threadi ng::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.Threadin g.Thread.Interr upt or
System.Threadin g.Thread.Abort. In the case of
System.Threadin g.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

Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
489
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 from them in MC++. So far so good...... I modified my MC++ project to run as mixed mode (removed nochkclr.obj, added msvcrt.lib, etc etc), and created 2 unmanaged classes which handled the calls to the static lib (btw all the code works fine in...
0
1487
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 managed C# dll before. Currently, I have an unmanaged dll, a managed C++ wrapper dll and a C# dll. I have managed to get enough exported from the unmanaged code to get a vaguely correct picture on the screen, however there is some odd behaviour. ...
5
10039
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
0
1465
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 am currently testing this and it fails. I have a native, unmanaged test application that links against my mc++ dll with a function entry point. Linking works fine, no errors. When I try to run in the debugger I see the output below (abreviated...
12
6105
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 out of which unmanaged exception //get thrown
3
1955
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 write a wrapper between unmanaged API and my managed app. Now on to the question: If there's an unmanaged API class called X with a defined method
4
2082
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 what is the "best practice" for disposing of pointers to unmanaged classes that you have newed in your constructor in MC++ For a better description of what is the standard affair I have tried looking online at:
1
3434
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 VS2003, and related techniques. I have found managed to unmanaged technique very easy in VS2005, but have not been able to build anything with unmanaged to managed calls. I have legacy (unmanaged C++) that would like to leverage the .NET...
12
12540
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 retreiving the data. Presently all of the c++ code is still in .NET 1.1, so we're using a _nogc bridge class wrapped in a _gc c++ class in order to facilitate this interop. But we've converted everything not c++ to .NET 2.0 and would love to
0
8678
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8609
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9030
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8899
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8871
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6525
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4621
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3052
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.