Problem with using OleLoadPicture in multithreaded application
-
I am having problems using
OleLoadPicture
in multithreaded application.:(( Is this function really thread safe and does not pose any threats? Does it have any disadvantages? - Like I've heard that it creates temporary files to cache the images we load. How to tackle the multithreaded scenario as my application is creating more than 100 threads, each of which uses this function, and then one of the threads crashes while callingOleLoadPicture
. Thanks in advance, Amit. -
I am having problems using
OleLoadPicture
in multithreaded application.:(( Is this function really thread safe and does not pose any threats? Does it have any disadvantages? - Like I've heard that it creates temporary files to cache the images we load. How to tackle the multithreaded scenario as my application is creating more than 100 threads, each of which uses this function, and then one of the threads crashes while callingOleLoadPicture
. Thanks in advance, Amit.Can you explain why you make 100 threads that use
OleLadPicture
?
WhiteSky
-
Can you explain why you make 100 threads that use
OleLadPicture
?
WhiteSky
The use of this function has been made in a dll. This dll is going to be used from a webservice. Right now I am trying do load testing through a C# appliaction and make the dll threadsafe. If I am using it for single thread then it works fine, but for multiple threads some threads finish their working successfully, and one of them crashes the application. There is no problem with image.
-
The use of this function has been made in a dll. This dll is going to be used from a webservice. Right now I am trying do load testing through a C# appliaction and make the dll threadsafe. If I am using it for single thread then it works fine, but for multiple threads some threads finish their working successfully, and one of them crashes the application. There is no problem with image.
Are you sure this error is of thread not OleLadPicture?
WhiteSky
-
Are you sure this error is of thread not OleLadPicture?
WhiteSky
The problem is not with the thread. The thing is that, some threads will finish successfully (They execute OleLoadPicture sucessfully) and suddenly in a random thread the function OleLoadPicture will not work, and then rest all threads which have yet to call this OleLoadPicture function, will not be able to execute it.
-
The problem is not with the thread. The thing is that, some threads will finish successfully (They execute OleLoadPicture sucessfully) and suddenly in a random thread the function OleLoadPicture will not work, and then rest all threads which have yet to call this OleLoadPicture function, will not be able to execute it.
How to run your threads immediately?
WhiteSky
-
How to run your threads immediately?
WhiteSky
WhiteSky wrote:
How to run your threads immediately?
I am not getting your question. Are you asking me post the code? Well, the threads are created from C# code and the call to function OleLoadPicture is in a C++ dll. This dll contains both managed and unmanaged code.
-
WhiteSky wrote:
How to run your threads immediately?
I am not getting your question. Are you asking me post the code? Well, the threads are created from C# code and the call to function OleLoadPicture is in a C++ dll. This dll contains both managed and unmanaged code.
oh :rolleyes: it seems that I asked of you:)if you dont have prolem with OleLoadPicture and all things is ok and also threads working without problem except a thread I think your problem is on memory why?because you said you got this error in random case so I think you need to free memory (I had a problem like this with threads but my program sudden terminated and I was wodering when I trace my prgroam line to line it was working but if I run it didnt work...my problem was I needed to close threads and free memory) Now my guess is this,Did you check for free memory?:)
WhiteSky
-
oh :rolleyes: it seems that I asked of you:)if you dont have prolem with OleLoadPicture and all things is ok and also threads working without problem except a thread I think your problem is on memory why?because you said you got this error in random case so I think you need to free memory (I had a problem like this with threads but my program sudden terminated and I was wodering when I trace my prgroam line to line it was working but if I run it didnt work...my problem was I needed to close threads and free memory) Now my guess is this,Did you check for free memory?:)
WhiteSky
As you said there was this problem too that the threads were not getting terminated. Then one of my friends suggested using mutex object. So I tried to use mutex whereever memory allocation is needed and it worked. :-D Also the threads are getting terminated properly. But still there is a problem and that is of the memory not getting freed. Anyway, I will look into it. Thank you, Amit.
-
As you said there was this problem too that the threads were not getting terminated. Then one of my friends suggested using mutex object. So I tried to use mutex whereever memory allocation is needed and it worked. :-D Also the threads are getting terminated properly. But still there is a problem and that is of the memory not getting freed. Anyway, I will look into it. Thank you, Amit.
If you want to use
CreateMutex
you need to callRleaseMutex
for each mutext(why its not free)
WhiteSky
-
If you want to use
CreateMutex
you need to callRleaseMutex
for each mutext(why its not free)
WhiteSky