Search found 72 matches

by Ksawery
Thu Oct 17, 2019 11:49 am
Forum: C++ Development
Topic: "Main thread" vs. other threads
Replies: 30
Views: 1381

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: 1381

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: 1381

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: 1381

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: 1381

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: 588

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: 1381

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: 588

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: 1381

"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: 588

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: 335

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: 335

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;
}
by Ksawery
Tue Sep 10, 2019 8:44 am
Forum: C++ Development
Topic: wxSingleInstanceChecker message
Replies: 6
Views: 335

Re: wxSingleInstanceChecker message

Thank you, it worked! I used the following code: { wxLogNull logNo; wxChecker = new wxSingleInstanceChecker(_T("PomiarWiazki")); } Two more things - i'm seeing the following message in the console: Gtk-Message: 10:43:55.126: GtkDialog mapped without a transient parent. This is discouraged. Is this s...
by Ksawery
Mon Sep 09, 2019 1:21 pm
Forum: C++ Development
Topic: wxSingleInstanceChecker message
Replies: 6
Views: 335

wxSingleInstanceChecker message

Hello, I'm using wxSingleInstanceChecker to ensure that only one instance of my application is running. It works fine, however sometimes I see a message stating "Deleted stale lock file 'home/.../AppName' ". I know that this message only appears when the app is terminated indirectly (e.g. by killing...
by Ksawery
Thu Aug 29, 2019 8:27 am
Forum: Platform Related Issues
Topic: How to set application icon in Linux
Replies: 5
Views: 635

Re: How to set application icon in Linux

Thank you, I added const to the .xpm file variable, and also the wxICON macro in my code, and now everything works fine - no more warnings or errors.

Code: Select all

m_frame->SetIcon(wxICON(icon));
Regards,
Ksawery