Running multiple functions simultaneously on a WinForms application - windows

I created a Winforms dashboard for my team using Powershell and I've put alot of features into the the thing (a tab that does webscraping, another tab that uses an API, another tab that sends emails, etc) and I just realized that I am unable to run different features simultaneously.
Some of the functions take awhile to actually run (like 1 minute or so) and while one feature is running, the entire winforms application is frozen until it finishes, before users are able to move onto another feature.
Is there a way around this? I know I can't be the only one who's ran into this issue. I want users to be able to run different dashboard functions simultaneously.
All of my code is currently in 1 .PS1 file which has over 1500 lines of code. I was thinking of maybe segmenting it off into different scripts and then having my dashboard call those other scripts once a function is invoked? Although I'm not so sure that would do what I'm looking to accomplish.
Any suggestions would be much appreciated.

Related

Is there a way to find out which process started another process in the rust programming language

I am making an app for my cousin that blocks apps at certain times of the day. I am trying to setup an easy gui based approach to block apps that is intuitive and easy to use. I get all of the apps from the start menu folders, then get their corresponding executables, and then put them in a grid list so that from the apps user interface, the user can add app and remove applications easily.
Unfortunately, some apps aren’t quite so easy… If an app has an updater app for it, most often, the shortcut in the start menu will refer the the updater app, then the updater will check for updates, apply updates, then run the program. But with my system, it would automatically pick up the updater program as the blocked app, not the actual app. That’s why I want to be able to see what program started another program. Then I can see if a program was started by the updater, then I will know that it is part of the app too, and I should block that app aswell.
I am pretty sure that this is possible, but I don’t know how to do this in rust. This forum says it should be possible: https://superuser.com/questions/541210/find-what-process-started-another-process.
The sysinfo crate should be helpful here - if you know the name of the app you want to block, you can use the list of all processes to find the process you want to block and find its parent process. You may have to repeat this traversal a few times to find the original launching process, but be wary about what process are blocking - you may find your way back to an OS/root process which you definitely don't want to block.

VS 2015 Form/Console Functionality in Application

This is more of a general theory question as I'm stuck on how to proceed since this is my first time developing an application...
I'm developing a reporting application in VS 2015 that requires two types of functionality. It needs to have a GUI so that users can interact with and create reports and those reports need to be scheduled via Windows Task Scheduler. I'm planning on using a Console Application for the scheduling portion. My question is, what would be the best way to implement this? As of right now I have two separate Projects in a single Solution. Is this the best route to take considering my needs or is there a better option that I'm not aware of? I've done some searching online but have not been able to find a valid solution. It's especially difficult since the scheduling portion needs to pull the application settings from the Windows Form Application.
Any help or guidance would be greatly appreciated. Thank you in advance!
The only reason you would need a console application would be if you actually needed a console interface. It doesn't sound like that's the case—the interface will be written in WinForms. Therefore, you don't actually need two separate applications. You can combine all the necessary functionality in a single executable.
The way to do this is by checking for command-line parameters that indicate whether the app should run interactively or headless. Probably, what you'll want to do is make the app run interactively when no command-line parameters are passed. This would be the normal case, the situation the user gets into when they double-click your app to launch it from Explorer.
When it comes time to schedule your app to run a task in the background (with Task Scheduler or anything else), you signal this by passing a special command-line parameter to your app. You can decide what this is, and you may need several of them if your app can do multiple things in the background. If configuration information/parameters need to (or can) be passed to the app to configure how it should perform the background task, you can pass these on the command line, too. Or, as you mention in the question, you could pull these settings from whatever was set/saved by the user the last time they ran the interactive version of the app.
The trick is just checking for these command-line parameters in your application's Main method. In the design I proposed, if there are no command-line parameters specified, then you just go ahead and create the main form like you normally would. If there are command-line parameters, then you need to parse them to see what action is being requested. Once you've parsed them and determined which background task should be run, you just run that background task—without ever creating/showing a form.
There are lots of different solutions for parsing command-line parameters. Using a library would probably be the easiest way, and also give you the most features. But if you just needed something really simple, like a /background mode, then you could easily write the code for this yourself, without taking a dependency on a library or needing to learn how to use it.
So you could do all of this with a single project in a single solution if you wanted to. Or, you could split different aspects of the functionality out into different projects that compile to libraries (e.g., DLLs), but still have only a single executable for simplicity.

How do I automate comparison of two external listboxes in Windows?

I've got a super tedious task to do for work that I'm hoping to get some guidance on semi-automating.
We've got a listbox in one program with a few hundred entries. I need to compare that against another listbox in a web app and figure out which values are missing or extra. I don't have access to the code from either.
Any advice on the best way to accomplish that would be appreciated.
For this sort of problem, you could try using a single Python script that fetches and compares your data.
For the web app portion, you can use Selenium webdriver - there are a lot of other ways to retrieve your web content (another Python web client library, or the curl command-line program), but webdriver should give you access to the contents of the listbox quite easily.
And for the Windows GUI app portion, you can try using pywinauto, swapy, or go directly to the MS UI Automation framework.
You could of course approach this with a different language, but I feel Python gives you the best of both worlds (web and native Windows app automation) without too much fuss. It can be nice being able to perform both types of tasks from one script.

Approach to testing GUI using MS TEST / Coded UI in VS2010

I am just jumping into testing of a GUI-heavy app written in C++(MFC) and C# (WinForms, WPF).
I have played with coded ui tests briefly, and I am happy with what I see. The trouble is that my program is non-trivial, so this does not work for me for 2 reasons:
VS 2010 Coded UI Test - Launch Referenced Application
There are 3 programs to launch in certain order, and I need to log in to one of them. Timing is important; I need to make sure that they have come up.
Start-up time is long, so I want to make sure that this set up is only done once per project.
When the project is done, I want to cleanly destroy this thing.
For each test I would want to make sure that the windows is active and is in the forefront at the beginning of each test.
What are some good approaches? If you find that this question is too vague, please let me know what it is missing.
There is code that gets generated for the coded UI tests. You can edit the coded UI test and add your own code to wait for things to occur before letting the next recorded step to take place. If you want to bring a certain application to the forefront, you can use Process.GetProcessesByName to get process information about your running application(s) and get its mainwindow handle to bring it to the front.
I you want to delay your test and wait some tasks (for example log-in or server response) you can check this article.
http://msdn.microsoft.com/en-us/library/gg316453.aspx

How to create Chrome like application in Delphi which runs multiple processes inside one Window?

Is it possible to create an "application group" which would run under one window, but in separate processes, like in Chrome browser? I'd like to divide one application into multiple parts, so that one crashing or jamming process cannot take down others, but still keep the look and feel as close to original system as possible.
I know the Chrome source is available, but is there anything even half ready made for Delphi?
I guess basically you would create multiple processes each of which creates a window/form. One of the processes has the master window in which every child window is embedded. That is as simple as calling SetParent. The windows in different processes would talk to each other using an IPC (Inter Process Communication) mechanism like named pipes or window messages.
See this question for an embedding example of using SetParent in Delphi. See this question for an example of using named pipes in Delphi.
Have a look at the Delphi code of HeidiSQL. It's a great open source MySQL client that implements this mechanism.
Read this newsitem that was posted when Chrome was released:
"Google playing catch-up with HeidiSQL?"
:-)
(source: heidisql.com)
Have a look at : http://blogs.microsoft.co.il/blogs/maxim/archive/2008/09/23/curiosity-killed-the-programmer-multiprocess-browser.aspx . The source of the app is in CSharp. I'm sure you can adapt it to Delphi.
Harriv, you can use a scheme based on plugins. where you have a main application and this dynamically load news functionality. There are several libraries available here I leave some.
(source: wikimedia.org)
Frameworks
TMS Plugin Framework
TJvPluginManager from JVCL
Delphi Plugin Framework
Hydra
Tutorials
Implementing Plug-Ins for Your Delphi Applications
How to make a Plugin for Your Application (Source Code)
Bye.
You can separate your application logic and execute it in several threads. That way, if one part of your application logic hangs up, you still have a responsive application. But you won't be able to put the GUI in multiple threads. The VCL requires you to execute all GUI related stuff in the main thread.
I am not sure about how Delphi operates but the standard procedure for multiprocess programming is forking.
You fork a new process with whatever code you want. Pass information to the forked process and let it run doing whatever it wants.
Can't explain multiprocess programming in one thread response. But look it up.

Resources