|
I would use criticalSections and Events.
I've used a circular que before to accomplish this. Each slot consisted of a buffer, allocated to a fixed size at start up (no more allocating required, unless user requested change at runtime). The lower priority thread checks for an event that says there is data in que (that can be read from the current head position). While the prioity thread can still be writing to the tail positon in the que (two seperate critical sections).
Basicaly, I automaticaly try to avoid thrashing memory by constantly allocating and deallocating memory. It slows things down and increases the chance that the a memory exception will occur. So if you can set a side memory for the sole purpose of communicating between your threads, you can avoid unexpected errors.
INTP
Every thing is relative...
|
|
|
|
|
Yes, I had thought this approach. Seems it's better than new and delete. I hate use new, coz u have to remember to delete it. u have to concern about memory leak or something. thank u.
|
|
|
|
|
I am trying to create and set evnets using Win32 API functions CreateEvent, SetEvent and OpenEvent.
Everything works fine if both projects are in the same language and environment (Visual C++) but when I try to create the event in a C++ application and set the event in a different application (VS.NET C#), the event does not exist.
Here is the code for both (c++ and c#):
C++
-----------------------------------------------------------------------------
#include <windows.h>
#include <iostream>
using namespace std;
int main()
{
// Get the handler to the event for which we need to wait in
// this thread.
HANDLE hEvent = CreateEvent ( EVENT_ALL_ACCESS, false, alse, "theEvent" );
cout<
|
|
|
|
|
Events are used within an application.
Use Mutexes.
CreateMutex(...)<br />
OpenMutex(...)<br />
ReleaseMutex(...)
this is this.
|
|
|
|
|
|
I have been too much lately.
I was confusing this with the Critical-section stuff.
Thanks for the correction.
this is this.
|
|
|
|
|
suezzz00 wrote: I suspect that the event that is created is not an OS event , but rather local to the running application.
No they are not. See my reply to khan++.
Your SetEvent PInvoke signature is wrong. You can use http://pinvoke.net[^] to get P/Invoke signatures for Win32 API functions.
The following code works fine for me.
C++
HANDLE h = CreateEvent(NULL, FALSE, FALSE, "TestEvent");
WaitForSingleObject(h, 5000);
cout << "past event";
C#
[DllImport("kernel32.dll")]
static extern bool SetEvent(IntPtr hEvent);
[DllImport("Kernel32.dll", SetLastError=true)]
static extern IntPtr OpenEvent(uint dwDesiredAccess, bool bInheritHandle, string lpName);
IntPtr handle = OpenEvent(0x000F0000 | 0x00100000 | 0x3, false, "TestEvent");
SetEvent(handle);
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
Hi,
In my win32 app, I want to draw a line as the user moves the mouse (just as you wud do in paint).
how do I do this. I tried SetPixel(), but it's like drawing dotted line rather than a full line.
I want to use LineTo(), but each time do I have to store the previous mouse point into a global variable as the starting point for lineto().
Is there any other easier way to do this.
Thanks.
|
|
|
|
|
Ann66 wrote: I want to use LineTo(), but each time do I have to store the previous mouse point into a global variable as the starting point for lineto().
Yes, you need to use lineto. No, the variable does not have to be global, why would it ? It is a member of the class.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
hi man
It is most common thing while learining Drawing by mouse
U can refer the book "Mastering VC++" BPB pubilcations.
There is a good detailed example in VC++ , will also need
good C++ knowledge to understand that .
Thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
Hello guys,
Is there any API, which will return the full path of the folder from where my application is running ?
Like GetModuleFilename() API , - but it returns the fullpath , including the filename.
thanks
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
-- modified at 15:24 Monday 24th October, 2005
|
|
|
|
|
Hi
You can extract Path easily, Like
GetModuleFileName(NULL,m_CurrentPath.GetBuffer(512),512);<br />
m_CurrentPath.ReleaseBuffer();<br />
m_CurrentPath.Delete(m_CurrentPath.ReverseFind('\\'),m_CurrentPath.GetLength()-m_CurrentPath.ReverseFind('\\'));
Iman Ghasrfakhri
|
|
|
|
|
Ghasrfakhri wrote: You can extract Path easily, Like
I know , but I am interested if there is a API function which will do this
"Success is the ability to go from one failure to another with no loss of enthusiasm." - W.Churchill
|
|
|
|
|
PathRemoveFileSpec Function
Removes the trailing file name and backslash from a path, if it has them.
BOOL PathRemoveFileSpec(LPTSTR pszPath);
|
|
|
|
|
as Blake Miller explained, PathRemoveFileSpec() exists for that but hey, look, it certainly does what one presented you before (with the reverse string search), and calling it will only slow your prgram down because of an added function call...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
toxcct wrote: PathRemoveFileSpec() exists...and calling it will only slow your prgram down...
Slower compared to what?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
compared to when you do the same thing without a function call...
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
Giorgi Moniava wrote: Like GetModuleFilename() API , - but it returns the fullpath , including the filename.
Hi Giorgi,
AFAIK, There is no such Api to Reterive Folder name only, you have to manually parse the FolderName !
"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
|
|
|
|
|
hi Giorgi Moniava
Yeh alok is right as far as i know
there is no such API availabe in VC6
thank you
Vikas Amin
Embin Technology
Bombay
vikas.amin@embin.com
|
|
|
|
|
I get error ERROR_ACCESS_DENIED when I DeleteFile a file.
Any idea what are the possible causes?
thanks
/c
|
|
|
|
|
File is open or read only.
Anyone who thinks he has a better idea of what's good for people than people do is a swine.
- P.J. O'Rourke
|
|
|
|
|
Hi,
Well was that file open (while deleting ),check for the file attributes ( the file is a read-only file, the function fails with ERROR_ACCESS_DENIED.
),this is all i could think at the first shot .
Regards
FarPointer
|
|
|
|
|
conceptus wrote: Any idea what are the possible causes?
The file is in use. Use Handle to determine what process has it open.
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|
|
I am creating an application where the user will need to define the location of two files. To make it easyer I want to give them the option to drag and drop the file onto the child window editbox system defined class. The problem is that the edit box will only handle the built in messages and passes all others onto DefWindowProc, including WM_DROPFILES. Any Ideas how I can make this work?
|
|
|
|
|
Has that window registered itself as a recipient of dropped files?
"Take only what you need and leave the land as you found it." - Native American Proverb
|
|
|
|