|
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?
|
|
|
|
|
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 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 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?
|
|
|
|
|
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. 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 call RleaseMutex for each mutext(why its not free)
|
|
|
|
|
Yes, I have used ReleaseMutex for each CreateMutex call. There must be some code that is doing leaking.
|
|
|
|
|
i've used the wizzard to add class derived from CRecordset for an access table (let's say CRSmytable).
i get "Too few parameters. Expected 3" exception thrown by CRSmytable.Open().
Any ideea why? Or, at least..what does this exception mean?
|
|
|
|
|
The exception means what it says. You are passing fewer parameters to the function CRecordSet::Open() than what it expects. BTW Can you post the code?
Nobody can give you wiser advice than yourself. - Cicero
|
|
|
|
|
i'm not passing any arguments..
The constructor of the recordset recieves a pointer to the opend connection to the database. From what i know, it should do a "select * from table"...
the code:
CRSLoads line(&pApp->db);
line.Open();
|
|
|
|
|
And if you set parameters for it what happens?
|
|
|
|
|
eusto wrote: Too few parameters. Expected 3
You are passing less parameter's to the function where you are calling it.See if you are missing out on passing some parameter values to the function.
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
CRecordset::Open() with no params should work..it works with firebird and mysql. It actually works with other tables in the access db that i use except this one I don't get it
|
|
|
|
|
I'll reply to my own post so maybe someone would benefit from it
The error was caused by the class wizzard wich inserted some columns that did not belong to that table. 3 of them
|
|
|
|
|
It means there is a discrepency between the number of columns being retrieved with the SELECT statement and the number of variables in the record set. Everything must match!
I would also suggest setting a breakpoint within CRecordset::Open() and single-stepping through that method so you'll know exactly what is going on. Until you can narrow an exception or an assertion down to the actual line, you're just guessing.
"Approved Workmen Are Not Ashamed" - 2 Timothy 2:15
"Judge not by the eye but by the heart." - Native American Proverb
|
|
|
|
|
Thanks i've solved it. It was exactly what you've said. I'm not used to access, i usually had a sql server behind my applications. The problem was between keyboard and my chair. I've generated the recordset from one db file and was running the program on another one.
|
|
|
|
|
As we can reallocate memory to the memory which was allocated withe calloc() function,using realloc()
How can we reallocate memeory for the memory which was allocated using new operator.
KIRAN PINJARLA
|
|
|
|
|
no way with new/delete.
BTW, what are you trying to achieve ?
if you're coding a container like a linked list, have you thought to use the STL ?
|
|
|
|
|
It doesn't work that way in C++. You have to write your own function to reallocate memory that's allocated with new, or you can use STL. (ie, vector)
std::vector<>::resize()
|
|
|
|
|
Thank You.
i want a to create a unsigned char * buffer whose size will be growing at runtime. For that i want to use vector<>.
how to use it for this?
first i want a BYTE* buffer[1000]; and at runtime everytime its size will be increased to 1000 and buffer of size 1000 should be appended to that buffer.
how this can be done using vector<>.
KIRAN PINJARLA
|
|
|
|
|
kiran.pinjarla wrote: first i want a BYTE* buffer[1000]; and at runtime everytime its size will be increased to 1000 and buffer of size 1000 should be appended to that buffer.
how this can be done using vector<>.
Is this what you want? Not sure if that's what you're asking though.
<br />
const int DEFAULT_SIZE = 1000;<br />
vector< unsigned char * > buffer(DEFAULT_SIZE);<br />
<br />
cout << "Before resize: " << buffer.size() << endl;<br />
<br />
buffer.resize(DEFAULT_SIZE + 1000);<br />
<br />
cout << "After resize: " << buffer.size() << endl;<br />
Before resize: 1000
After resize: 2000
|
|
|
|
|
It's also worth noting that if you need the pointer to the beginning of your buffer, you can use
BYTE* pBuffer = &buffer[0]; // address of the first element of the vec
|
|
|
|
|
Link2006 wrote:
buffer.resize(DEFAULT_SIZE + 1000);
cout << "After resize: " << buffer.size() << endl;
sorry, but little problem.. you cannot get the string as a whole.. it every charcter has it unique character...
better you have unsigned char instead it's pointer!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief And you
|
|
|
|