I have the following code below. I am getting a memory access violation when accessing cmd->query_string in the loop function. The loop() function is running in another thread. The cmd object appears to be destroyed after calling the send_command function. How do I create an object on the heap and access the query_string.
I am new to C++ programming and i have a small assignment.
How to implement a thread safe class to manage a queue of objects. Accessing the front of the queue should be a blocking operation when the queue is empty.
Alright, so I'm making a windows form with a few hundred buttons, and one button will change color based on data the program receives over a socket. This is what I have, and it kind of works, but I don't want to have to make another if statement for all 260 buttons.
void hitmiss(std::string u){ std::string^ ind = reccdata2(); if (u == "button6"){ if (ind == "1"){ this->button6->BackColor = System::Drawing::Color::Red; this->textBox2->Text = L"hit";
[Code] .....
What I want to do is make it more like
void hitmiss(System::String^ u){ std::string^ ind = reccdata2(); if (ind == "1"){ this->u->BackColor = System::Drawing::Color::Red; this->textBox2->Text = L"hit";
[Code] ....
But it returns the error that u is not a part of Form1.
Table with primary key already set-down in ACCESS. when insert records into the table by Execute() function of cdaodatabase, to some extense, the records are not put behind the last record as wished, otherwise randomly into other places!
now i want to do some kind of operation to order the table after insertion by cdaodatabase or some others. how to?
I have a class which I wrote and one of its object is "SerialPort" .NET class. In my MainWindow I created instance of my class called "SerialPortComm", then I send through some functions of mine, commands to the Serial Port, and I receive answers through "DataReceived" event.
But when I trying to use Dispatcher.BeginInvoke to write my data I have received (successfully), nothing shows on the RichTextBox which I'm trying to write to.
What can caused that, and How I can make it works?
SerialPortComm.cs
public partial class SerialPortComm : UserControl { public SerialPort mySerialPort = new SerialPort(); public void Open_Port(string comNumber, int baudRate) { mySerialPort.PortName = comNumber; mySerialPort.BaudRate = baudRate;
if we don't provide the acces modifiers for base class and we need to manipulate the private data of base class in derived class. Is there anyway to acces the private data members? Here's a coding example
class A { private : int a; }; class B : public class A { public : void displayA() { cout<<a<<endl; } };
how i can acces the a of base class A in derived class B without acces modifiers.
This has been bothering me for a while now, and I finally put together an example:
#include <iostream> #include <string> using namespace::std;
[Code]....
In the code above, the two classes hold pointers to each other, and that's fine but it doesn't seem right since C++ prefers to pass by reference. Yes, it can still do that (see testbox and testball) but even that seems odd to me because still you need to use pointer notation for the enclosed object. Am I the only one who feels this way, and should I just get over it? Or am I missing something that would allow an object to hold a reference?
I was working on a problem that was best solved with chaining threads together using a blocking thread-safe queue. Eg threads A and B pass data to each other using a queue ... a simple producer consumer design A -> B. This has two benefits: 1) being that there is a buffer between the two threads to cache for a slow consumer and 2) allows for better throughput when loads of data are high because the two can run in parallel. Most of the time the design works well under load. but I found when pushing data through the threads intermittently, i.e. once about 0.5 seconds it ran poorly, mostly from what seemed to be latency introduced during the OS waking up of the consumer thread B.
What i have come up with to solve this issue is what i call an .... Its a wrapper around a basic thread safe queue and adds one extra function called .... The idea here is that if you have a simple case (or perhaps a slightly more complicated case) of two threads in a prod cons design and you know the producer will create or received the data, process it, and then push onto the queue, why not give the consumer thread a heads up to let it know the data is about to arrive. In this case call .... In this way you can have the consumer thread in a polling state anticipating the arrival of data and avoid the time to schedule it back to a running state.
Anyway, i have some code below and I was looking to get some feedback. I have tested it somewhat and it does improve the responsiveness quite substantially.
progd->count was devised to stop the thread when the recursion ended by posting a message to the main window. When it reaches 1, the def procedure sends the WMU_DISC_DONE message to set the event
All that *appears* to work; however, if I cancel the recursion thread, the list view continues to populate for a bit and then deletels all but 1 item though I send the message LVM_DELETEALLITEMS.
If I move the (tmp->canceled == TRUE) test inside of the do-while, the app gets loopy.
I have a small problem with my program. It is kinda a mess but I will try to explain you what I am trying to do. I have some threads. One of it, it attempts to detect a game client. So my code is sort of like that:
DWORD ProcessID; // The process ID of the game client void test() { char* text;
[Code]....
So basically, its like the variable changes, but only inside the thread... why does that happen?
However, since it is multithreaded, I would like (and need!) to have one dedicated vector per thread. I haven't been able to find an example of how to do this online. Is it even possible?
I have an issue where I iterate through devices and make driver API calls. Unfortunately, these calls take too much time and they are interrupting my real-time scheduler. I have 12 cores, of which one is 100% and the others are < 1%.
I'd like to multi-thread this thing. So far, I've replaced:
for (DeviceIterator d = devices.begin(); d != devices.end(); ++d) { d->Write(words, numwords); }
My problem is that this didn't improve performance at all. The main thread still takes too long to execute. Is there something I need to do to prevent the main thread from blocking?
// mergefile2norecreation.cpp : definisce il punto di ingresso dell'applicazione console. // // Filemerge.cpp : definisce il punto di ingresso dell'applicazione console. //
#include "stdafx.h" int _tmain(int argc, _TCHAR* argv[]) {
There is a smart way to make a merge sort between 2 file already ordered? I had try it ,and above there is my result,it works but i think that it's possible to do it in a smart way...