Search found 75 matches

by Ksawery
Thu Oct 17, 2019 1:30 pm
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 2708

Re: "Main thread" vs. other threads

The application now successfully compiles, but unfortunately crashes after 20 seconds or so, for some unknown reason. I seem to be getting different errors reported in the console each time. For example: corrupted double-linked list or (PomiarWiazki_Gateway:18974): GLib-GObject-[1;35mCRITICAL[0m **:...
by Ksawery
Thu Oct 17, 2019 12:10 pm
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 2708

Re: "Main thread" vs. other threads

to make clean multithreading design you need blocking functions, and better blocking with timeout. do this Modbus library has any to read the data? or you are just polling modbus devices kinda to control their state or something? which lib are you using for modbus? I'm using the latest version of t...
by Ksawery
Thu Oct 17, 2019 12:06 pm
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 2708

Re: "Main thread" vs. other threads

in simple words cMain has declared virtual method, but not implemented it. and there are no other implemented virtual methods in cMain. Thank you, this was it! I declared a virtual method that was meant to override a method in the wxThreadHelper class, but I removed all helper thread code from the ...
by Ksawery
Thu Oct 17, 2019 11:49 am
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 2708

Re: "Main thread" vs. other threads

Here is the event table in cMain: wxBEGIN_EVENT_TABLE(cMain, wxFrame) EVT_COMMAND(wxID_ANY, wxEVT_RTU_UPDATE, cMain::OnModbusUpdate) EVT_BUTTON(10001, cMain::OnButtonClickedWsun) EVT_BUTTON(10002, cMain::OnButtonClickedWysun) EVT_BUTTON(10003, cMain::OnButtonClickedCalibrate) EVT_MENU(wxID_PREFERENC...
by Ksawery
Thu Oct 17, 2019 11:11 am
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 2708

Re: "Main thread" vs. other threads

So i'm trying to implement the sending of custom events to my application windows from wxThreads. I'm using the following example for this purpose: https://wiki.wxwidgets.org/Inter-Thread_and_Inter-Process_communication#Sending_custom_events_to_the_main_thread After implementing this, I keep seeing ...
by Ksawery
Wed Oct 16, 2019 6:09 pm
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 2708

Re: "Main thread" vs. other threads

Thanks for your replies. It does indeed seem that I occupied all available cores with the threads - and then some. So obviously my application worked very slowly. I'm new to multi-threading, so i'm still learning the best practices. I like the suggestion of sending events to the main thread, from th...
by Ksawery
Wed Oct 16, 2019 1:25 pm
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 2708

Re: "Main thread" vs. other threads

Thanks again for your replies. So what seems to be happening, is that the application eventually starts, albeit very slowly. It's then very unresponsive, and has a very high memory/CPU usage. So there's definitely something wrong with the way that I implemented multithreading. I assumed that the thr...
by Ksawery
Wed Oct 16, 2019 12:09 pm
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 2708

Re: "Main thread" vs. other threads

Thanks for your reply, that's very helpful. My use of threads is as follows: wxThread 1: Modbus RTU Communication (Serial Port 1) wxThread 2: Modbus RTU Communication (Serial Port 2) wxThread 3: Modbus TCP/IP Communication (Ethernet) All three threads interact with the same data structure, so critic...
by Ksawery
Wed Oct 16, 2019 10:59 am
Forum: C++ Development
Topic: Multi-threaded application
Replies: 4
Views: 1037

Re: Multi-threaded application

Thanks.
by Ksawery
Wed Oct 16, 2019 10:54 am
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 2708

Re: "Main thread" vs. other threads

Ok, thanks. Two more questions that I have: 1. Is there a healthy limit to the number of threads used in my application. 2. Is it ok to use wxThread and wxThreadHelper classes alongside each other? My application currently uses 3 wxThreads and 4 wxThreadHelpers. The 3 wxThreads are created within a ...
by Ksawery
Wed Oct 16, 2019 9:14 am
Forum: C++ Development
Topic: Multi-threaded application
Replies: 4
Views: 1037

Re: Multi-threaded application

Thank you, I'm currently following your suggestion, but haven't tested the application yet. Quick question - how does wxCiticalSection work exactly? As I understand, all threads trying to access the same memory location should use the same wxCriticalSection?

Regards,
Ksawery
by Ksawery
Wed Oct 16, 2019 9:09 am
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 2708

"Main thread" vs. other threads

I have a quick question regarding multithreading inside a wxWidgets application. As I understand, there is a "main thread" in the application, which procedurally creates and manages the application. My question is: what would happen if an infinite while loop was placed in two different frames simula...
by Ksawery
Sat Oct 12, 2019 12:52 pm
Forum: C++ Development
Topic: Multi-threaded application
Replies: 4
Views: 1037

Multi-threaded application

Hello, I'm currently implementing an application where I would like to make use of multiple threads (probably 3 threads, but maybe more in the future - it would be nice if I could create any number of threads based on a single parameter). Each thread will handle communication via Modbus RTU or TCP/I...
by Ksawery
Tue Sep 10, 2019 9:26 am
Forum: C++ Development
Topic: wxSingleInstanceChecker message
Replies: 6
Views: 609

Re: wxSingleInstanceChecker message

Using wxApp::SetAppName() helped set the title of the error window, thanks. How about the GTK message, is there a way to suppress it or avoid it? It only pops up when displaying the error window. Edit: I tried using wxMessageBox instead of wxLogError, and i'm still seeing the gtk message. Regards, K...
by Ksawery
Tue Sep 10, 2019 9:04 am
Forum: C++ Development
Topic: wxSingleInstanceChecker message
Replies: 6
Views: 609

Re: wxSingleInstanceChecker message

I'm using wxLogError() to display the message, after checking if another instance is already running:

Code: Select all

if (wxChecker->IsAnotherRunning())
{
    wxLogError(_T("\nProces już istnieje!"));
    delete wxChecker; // OnExit() won't be called if we return false
    wxChecker = NULL;
    return false;
}