Click here to Skip to main content
15,887,596 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: WaitForMultipleObjects Pin
ThatsAlok29-Aug-11 23:54
ThatsAlok29-Aug-11 23:54 
AnswerRe: WaitForMultipleObjects Pin
Malli_S30-Aug-11 0:11
Malli_S30-Aug-11 0:11 
AnswerRe: WaitForMultipleObjects Pin
«_Superman_»30-Aug-11 4:38
professional«_Superman_»30-Aug-11 4:38 
QuestionBluetooth _ What is the GUID for " Text transfer" Pin
Vijay Rajanna29-Aug-11 10:11
Vijay Rajanna29-Aug-11 10:11 
AnswerRe: Bluetooth _ What is the GUID for " Text transfer" Pin
«_Superman_»30-Aug-11 4:43
professional«_Superman_»30-Aug-11 4:43 
QuestionBluetooth socket not receiving data sent from client Pin
Vijay Rajanna29-Aug-11 7:51
Vijay Rajanna29-Aug-11 7:51 
AnswerRe: Bluetooth socket not receiving data sent from client Pin
«_Superman_»30-Aug-11 4:44
professional«_Superman_»30-Aug-11 4:44 
QuestionCreateFile, ReadFile and Writhe file thread Pin
Bogdan Markovic29-Aug-11 3:28
Bogdan Markovic29-Aug-11 3:28 
Hello to everybody,
I wrote a simple code for data reading and writing from USB HID device.
My code looks as follows:
VB
HidDeviceObject = CreateFile (
        (LPCTSTR)DevicePath,
        GENERIC_READ | GENERIC_WRITE,
        FILE_SHARE_READ | FILE_SHARE_WRITE,
        (LPSECURITY_ATTRIBUTES)NULL,
        OPEN_EXISTING,  
        0, 
        NULL);

In this way I open device for communication (synchronously).
Now I create two threads, one for data reading and one for data writing to device.
This is read thread:
VB
while(TRUE)
{
  if(!WRITE_BUTTON)
  {
    if (HidDeviceObject != INVALID_HANDLE_VALUE)
	{
	  CancelIo(HidDeviceObject);
	  int Result = ReadFile(HidDeviceObject, &InputReport, sizeof(InputReport), & NumberOfBytesRead,NULL);
	}
   }
}


where WRITE_BUTTON is flag( if I click on write button in my GUI, WRITE_BUTTON is equal to 1, else 0)
My write thread is:
C#
while(TRUE)
{
    if(WRITE_BUTTON)
    {
        if (HidDeviceObject != INVALID_HANDLE_VALUE)
        {
            CancelIo(HidDeviceObject);
            int Result = WriteFile(HidDeviceObject,&OutputReport, sizeof(OutputReport), & NumberOfBytesWriten, NULL);
            WRITE_ROPRT = FALSE;
        }
    }


I am new in thread programing, and I need help fast. If I comment one of the threads, second one works fine. Where is my mistake? How to make them to works together in the same time? I want to send some data to device and wait for device to respond to me. When I open device with async flag (asynchronously) ( instead 0 in CreateFile function, I put FILE_FLAG_OVERLAPPED) threads works fine together, and I can send data to device and "capture" response from it.
Thanks
AnswerRe: CreateFile, ReadFile and Writhe file thread Pin
Malli_S29-Aug-11 4:10
Malli_S29-Aug-11 4:10 
QuestionPorting MFC Application [modified] Pin
pix_programmer28-Aug-11 23:06
pix_programmer28-Aug-11 23:06 
AnswerRe: Porting MFC Application Pin
Sarath C28-Aug-11 23:51
Sarath C28-Aug-11 23:51 
QuestionRe: Porting MFC Application Pin
pix_programmer29-Aug-11 0:20
pix_programmer29-Aug-11 0:20 
AnswerRe: Porting MFC Application Pin
Albert Holguin29-Aug-11 5:02
professionalAlbert Holguin29-Aug-11 5:02 
AnswerRe: Porting MFC Application Pin
Rolf Kristensen29-Aug-11 8:53
Rolf Kristensen29-Aug-11 8:53 
QuestionRe: Porting MFC Application [modified] Pin
pix_programmer29-Aug-11 18:25
pix_programmer29-Aug-11 18:25 
AnswerRe: Porting MFC Application Pin
Rolf Kristensen29-Aug-11 20:20
Rolf Kristensen29-Aug-11 20:20 
QuestionWriting multiple files simultaneously inside the loop Pin
VCProgrammer28-Aug-11 19:38
VCProgrammer28-Aug-11 19:38 
AnswerRe: Writing multiple files simultaneously inside the loop Pin
Sarath C28-Aug-11 23:53
Sarath C28-Aug-11 23:53 
AnswerRe: Writing multiple files simultaneously inside the loop Pin
Code-o-mat28-Aug-11 23:58
Code-o-mat28-Aug-11 23:58 
AnswerRe: Writing multiple files simultaneously inside the loop Pin
Rolf Kristensen29-Aug-11 8:52
Rolf Kristensen29-Aug-11 8:52 
QuestionCode changes req. to improve 64 bit application performance Pin
am 200928-Aug-11 18:22
am 200928-Aug-11 18:22 
AnswerRe: Code changes req. to improve 64 bit application performance Pin
Rolf Kristensen28-Aug-11 20:30
Rolf Kristensen28-Aug-11 20:30 
AnswerRe: Code changes req. to improve 64 bit application performance Pin
MicroVirus29-Aug-11 1:33
MicroVirus29-Aug-11 1:33 
QuestionManifest in resource script? Pin
Groulien28-Aug-11 9:57
Groulien28-Aug-11 9:57 
AnswerRe: Manifest in resource script? Pin
David Magnotti28-Aug-11 13:34
David Magnotti28-Aug-11 13:34 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.