Giving the user some information on the run status of my program - user-interface

I made a simple GUI for my Racket batch data processing program that accepts a user specified input file and writes to a user specified output file. Once the user has specified those files, all they have to do is click a "Run" button. The program works, but the GUI becomes unresponsive while running the batch processing logic. Since it can take a long time to finish, I want to give the user some assurance that it hasn't crashed. How can I avoid this unresponsiveness (at least the frozen window part)?

Run the batch processing in a thread.
See Racket docs on thread

Related

Windows - Opening a file from code and wait for it to be closed

I need some help and/or advice please.
I'm opening a file from code in either the default associated windows program or with a selected windows program using either ShellExecute or CreateProcess. I then wait for the process to complete. But this does not really work for me because:
Let's say the default associated program for text files (*.txt) is Notepad ++ (NPP). For the process to complete, NPP must not be open to start with and must be closed to complete the process.
But if NPP is already open, the file will be opened in the already opened NPP. But I do not necessarily want to close NPP to complete the process, I just want to close the opened text file and need to detect that the file has been closed and not NPP.
So I realised that waiting for the process to complete is not going to work. I've tried several things like trying to detect if the if the file is opened in another process but have not had any success.
So my question is, what would be the best method to detect when a file is open or in use and vice versa?
It sounds like you want to know when the file handle is "closed", not necessiarly when the program that operated on that file has exited.
Your question is closely related to this question. You could reference that to periodically poll the process handle to see what files are open. There will be timing issues - it might take a few seconds for the process to open the file in the first place.
There are also tools such as Handle.exe that may be useful.
However - none of these solutions are perfect. Some apps, including Notepad.exe, just open the file, read the contents, and immediately close the handle. When the user clicks "save", the file is re-opened for writing, contents saved back to disk, then the file handle is closed again.
A simpler approach would be to periodically poll the last-modified timestamp on the file via GetFileTime. When it changes, you could assume the file has been "Saved". Or apply this technique with some combination of the above and/or waiting for the application that was launched to exit.

How to close cmd after LabVIEW code executes

When I am running batch file through LabVIEW by using System Exec.vi, two cmd windows are appearing. The second one executes command of the batch file and closes after that, while the first one doesn't close. I have tried to use this solution, but it doesn't work. Is there any way to close that first cmd ?
P.S. If I run batch file not through LabVIEW, but just by double clicking on it, two cmd windows close after execution
It's hard to tell, but I think you've misunderstood the directions given at that link. The batch file should contain the executable and its options, but you just pass the batch file to the System Exec VI. I'm guessing what's happening here is the batch file is getting called twice, and some process that the first call depends on is getting hijacked by the second call, so that when the process ends, the second call gets notified and stops itself, but the first call is left hanging. Or something like that.

Windows: Can the return value of a process running C++ code be accessed if you don't run from command line?

I know that you can access the return value of the process using the command line or by having one process create and run the other. However, if I just make an *.exe and double click it, does the return value go anywhere that I can access? If so, where? Could I change any settings so that, if my process returns EXIT_FAILURE, Windows will handle things differently than if it returns EXIT_SUCCESS?
No, I don't think anything retains the exit value of a process started in that way. When you double click on a shortcut or executable, Explorer creates the process and then immediately closes the handles because it no longer cares what happens.
You could write a program that calls OpenProcess on the process of interest while it's running. (It would have to have a way to discover the process ID before the process exits.) OpenProcess will give you a handle to the process. The program could then wait on that handle. When the process exits, the program could use the handle to retrieve the status code and do whatever it is you want it to do.

How do I monitor the status of a program running in Windows 10?

I know we look at the list of process with tasklist command.
However, what I would like to know is what happens within the process.
First part:
For example, I am running MS Word.
So I click on "File" button. It will cause the drop down box to open.
However, what happens in OS and is there anyway of monitoring this?
(Like a debugger or a log message to track the action that will show like
"MouseClicked Button File" and "Drop down opened")
Second part (If there is no solution to the first part):
As programmers we write programs in different languages like java, C/C++ and so on but all of them are compiled into .exe/.jar files.
So I should be right to say that all of this compiled are readable by the OS so we should be able to write the program to create a software that will be able to do the above all of them are read by the OS.
Third Part:
Please give me some tips to start working on this project that will show the status of a running program.

How to display the main window of a process in another Windows session?

When running a Scheduled Task under Windows to launched batch processes under a dedicated account, you could want to see output of theses processes.
These sub-processes could be either or both graphical or character based applications
As there are running in a different Windows Logon session, I cannot find way to display their output. There are like ghost processes
I would expect being able to use the show Window command from Process Explorer, but even via running Process Explorer under the dedicated account used to run the task (via runas), it is not working
Is there a way to do it ?
References : http://www.brianbondy.com/blog/id/100/
I believe that once created, a window cannot be transferred to another window station. Also, I doubt it is possible to open windows in another session. For character-based applications you are better off writing the output to some file and examining that file. For graphical applications you are out of luck with task scheduler. You may want to write a simple VBS script that wakes up at a certain time and runs your graphical task(s) and run it upon user logon, e.g. along the lines of a script from this page:
http://social.technet.microsoft.com/Forums/scriptcenter/en-US/d9465815-87e2-43df-a0fe-4a23c16dca99/need-a-time-schedule-in-vbs-script-to-execute-something

Resources