You can't do something like that. Furthermore, it is almost impossible to manage: suppose that a thread starts to read a couple of bytes, then another thread comes in and read another couple of bytes: how will you manage such a situation ?
What you can do however, is have one thread that reads the port and sort the information for the different threads to process: there's one buffer for each thread processing data and the thread which reads from the port puts the data in the appropriate buffer (and signal the processing thread that data is available).
Anyway, for which reason do you need to have multiple threads accessing the port ?
Ok, it is for writing the port, not reading the port then. In that case, I think it is a bit more easier. Anyway, you still need to same principle: the thread that writes to the port creates a queue in which the other threads can push their messages. The access to the queue is protected by critical sections, so that multiple threads cannot write data at the same time in the queue.
To make things a bit easier, you will first need to wrap the SMS data into a specific class (makes it easier to manipulate). Then, you will need to create the queue class: to make things a bit more simple for now, this queue wraps a std::queue with the type of your SMS class. You'll then need to secure the access to the internal queue by using critical section.
After a bit of googling, I found this implementation[^] of a thread-safe queue. Try to understand the code first, then come here and ask specific questions about which part you didn't understand. Then, once you really understood how the code work, you can implement your own version of the queue.
in my MFC Dialog based application ,i have a list box which contains list of text files with their full file paths. I also have edit box in my MFC application, now i want to display the contents of the file(selected from the list box)into the EditBox. in short i want to open the file in that edit box.... can n e buddy help me out!!!
i am using ReadDirectoryChangesW synchronously to monitor a Drive...when ever any file is copied the same is validated and deleted if the file fails the validation check..and the loop continues its wait for next change on the directory monitored...however, when i copy a folder there is an issue..if the folder is invalid and deleted, then the code exits out of the loop of monitoring the directory....i am using recursive deletion to delete folders which are found invalid......
please could i get some help on how to fix this issue......
Without seeing your code it is impossible to guess what your program is doing. Please edit your message and add the relevant part(s) of your program, and don't forget to use the code block button to surround the code with <pre></pre> tags, to help readability.
Just say 'NO' to evaluated arguments for diadic functions! Ash
I am trying to multi-thread my OpenGL code but I have been having trouble. At first, I thought that using opengl inside an alternate thread was impossible, so I just did loading operations and passed the data to opengl in the main thread (I knew once I started passing too much data the main thread would lockup, and noticeably freeze the execution of the program while the data was being moved). I found some forum threads discussing opengl and multi-threading but they don't discuss the details that I'm looking for. namely, how and where do I use wglMakeCurrent() and wglShareLists().
I have been trying to create a display list in the alternate thread with the instructions outlined in the aforementioned forum posts but it crashes every time. I can load the model data, I can even load shaders, but loading a model (of any size) crashes the program.
I will show some code snippets but there is really too much to put in one post:
//This is the code initializing the 2 Render Contextsif (!(app.hDC=GetDC(app.hWnd)) || // Get A Device Context?
!(PixelFormat=ChoosePixelFormat(app.hDC,&pfd)) || // Did Windows Find A Matching Pixel Format?
!SetPixelFormat(app.hDC,PixelFormat,&pfd) || // Able To Set The Pixel Format?
!(app.hRC=wglCreateContext(app.hDC)) || // Able To Get A Rendering Context?
!(app.hRC_thd=wglCreateContext(app.hDC)) || // Get the second context (for loading in parallel thread)
!(wglShareLists(app.hRC, app.hRC_thd)) ||
!wglMakeCurrent(app.hDC,app.hRC)) // Try To Activate The Rendering Context
This next bit is all the initialization and render using opengl
GLuint o; // display list handle
vector<v3> v,n; // verts, norms
vector<v2> u; // texcoords (UVs)
vector<face> f; // polygons (faces)bool done = false;
void load_thread(void* null) // alternate thread entry point
wglMakeCurrent(app.hDC, app.hRC_thd); // works fine (seemingly)
load_rs_shdr(); // works fine
load_obj("cell.obj", v,n,u,f); // works fine
gen_display_list(o, v, n, u, f); // crashes my program
done = true;
init_med(v3(0,0,0)); //function to initialize opengl (enable depth, lighting, etc...)
set_light_const(v3(0,10,0), v3(1,1,1)); //enable a light
_beginthread(load_thread, 0, (void*)0); //function declared in process.hreturntrue;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
I know for sure that my loading functions work, I've been using them for a while now inside my single threaded apps.
As far as I know, when you do a screen shot, you get what is on the screen. If part of your content is hidden by other windows, then you need to bring it to the front to take a screen shot. If it is too large for the screen and is partially hidden because it has scrolled, then you have a different problem.
Perhaps someone else has a better idea.
CQ de W5ALT
Walt Fair, Jr., P. E. Comport Computing Specializing in Technical Engineering Software
Yes, you can send the window the WM_PRINT[^] or WM_PRINTCLIENT[^] message and ask the win32k subsystem to paint into the device context you pass in the wParam. Not all windows support these messages (such as windows using DirectDraw) so your results may vary.