Simultaneous processing in Powershell - powershell

I have been stuck with this problem for about 2 months now. I have 2 different GUI's, one built with Windows Forms and the other is WPF. They each have text boxes that I want to refresh and update every few seconds. I have accomplished this no porblem, however, using both the $Form.Refresh() and textbox.Refresh() method in loops mean you cannot interact with the rest of the GUI's tabs and buttons as I had to put it into an infinite loop to update the text boxes every few seconds.
I have explored the start-job to do the data gathering for the text boxes, but I still get stuck with trying to update the text boxes without looping the script to use the Receive-Job.
Can someone tell me how to go about independently updating the cells, while still allowing other interaction with the GUI. Right now I have an external GUI that is stuck in an infinite loop to display the data while the master GUI is free to do the rest of the work and kill the data GUI when completed.

The simplest thing I end up doing for infinite loops in GUI is to add this inside the loop.
[System.Windows.Forms.Application]::DoEvents()
It is quick and dirty but works. So you can use this in the loop that waits for the Receive-job.
On another note, Jobs are not too efficient. Each job creates an individual process and can get messy when you have multiple jobs. If you are running into that, check out PowerShell Runspaces. Best way I know to handle multithreading.

Related

The simulation model time slows down in virtual mode

I am currently building a model on a manufacture process line and the simulation was running fine without errors. Suddenly when I entered in virtual mode to run quickly the simulation, the model started to slow down although the step is high. I am trying to identify where the issue is but nothing is working. At a certain time , the simulation just stops while the step is still running.
This is a picture of the pallete, maybe the experiment is causing this.
You created an infinite loop, this can be triggered by various things in your model.
Likely, you have a ' while' loop not finishing, could also be a condition-based transition.
You need to find this yourself, though. 3 options:
(easy): Check the model logic yourself and find the problem
(easy): nudge yourself to where it stops with traceln commands (see where they stop showing, getting you closer to the culprit)
(harder): Use a profiler (google "AnyLogic profiling" or similar if you are not familiar)
Benjamin is correct, you have created an infinite loop. Click on the "Events" tab in the developer panel and see which events are scheduled to occur at about the time that your model slows down to 0 days/sec. You can also pay attention to the "Step: " counter at the bottom of the developer panel and see where the step count spikes - e.g., if your model has roughly 10k steps per day, and suddenly starts climbing to 400k steps around 25.99 days, you can pay attention to which things are happening in your logic at that time and narrow down where the infinite loop is created. traceln will also help immensely

Running Goal Seek Function in Excel using Powershell

I need to use the goal seek function in Excel to process several calculations in background process.
Already using approach using while looping and search value itself by changing cell and check the output value.
I wonder if there is any other option to calculate goal seek value with background process, for example trigger goal seek using PowerShell or anything tools.

GroupByKey not updating on very long PTransform with a Window

I'm working on a streaming Java Apache Beam (2.13.0) pipeline that is running in Google Cloud Dataflow. I have a long running PTransform (for a single input, it does a lot of work, outputs multiple outputs and can take >10 minutes).
I want to return early results from the processing to the user. I have a Window and Combine step afterwards. Early triggers do not seem to work with a long running PTransform. The Combine step outputs elements after the PTransform finishes processing the element (rather than returning early results).
I've tried many different early Window functions. E.g. I've tried doing forever element count triggers and it does not work. Ditto for forever processing time-based triggers (e.g. every 10 processing seconds). I've tried GlobalWindows, Fixed Windows, Session Windows, etc.
Here is rough pseudo code for what I'm doing.
p.apply(PubsubIO.readStrings().fromSubscription(options.getInput()));
.apply(FlatMapElements.via(new LongRunningCalculation()))
.apply(<I've tried a variety of window functions>)
.apply(Combine.perKey(new SumMetrics()))
.apply(DatastoreIO.v1().write().withProjectId(options.getProject()));
For the Window functions, I've tried many different Window functions to see if I can get anything to return early. I can't get it to return early.
Here is a basic one.
Window.into(new GlobalWindows())
.triggering(Repeatedly.forever(AfterPane.elementCountAtLeast(10)))
.withAllowedLateness(Duration.ZERO)
.discardingFiredPanes());
Even for this one, Even if the Window has added >>10 elements, the GroupBy in the Combine step does not output any rows.
Expected: If I have a long running PTransform, I'd still expect early triggers to still fire.
Actual: I can't seem to get early triggers to work.
Any advice?

event don't not be scheduled in anylogic

In AnyLogic, how can I let the event be touched after running the simulation, so each time I don't need to copy the table from Log and paste it to excel. I tried to use the database to store the variables but it seems too complicated and I couldn't work with it!
When I ran model in anylogic, event can't be touched off. It showed that event don't be scheduled. I try many ways, but it is also that.
To answer the question about calling event after simulation:
In main, you can call a function on destroy. At the experiment level, you can also call a function after run, iteration, or experiment.

Delayed Execution on Edit with Google Apps Script

I have a relatively large spreadsheet (300 rows, 30 columns) that I color based on the values in the spreadsheet. I'm doing accessing the API minimally using only two accesses:
getValues(...) to access all the values of the data range.
setBackgrounds(...) to set all the backgrounds of the data range.
This runs in about half a second or less. However, it gets in the way if I make it run on every edit using onEdit(), but I also don't want it to be updated at regular time intervals when I'm not editing it, seems like a waste. Is there a good way to make the script run in a "delayed" way, updating at regular time intervals while I'm editing?
Firstly, I would say you should look at Google Sheets' conditional formatting (Format > Conditional formatting menu item in Sheets) -- you may be able to do much of what you need without involving Apps Script at all.
Failing that, you can set up a regular time-based trigger to check for edits and change the backgrounds appropriately. You can support this trigger with a separate onEdit() trigger to record what has changed internally. The flow goes like this:
A change is made and onEdit() triggers
The onEdit() trigger only records the changed cell locations to a local variable or Cache
A time-based trigger fires every minute/hour/whenever
The time-based trigger checks the cache for edited cells, alters their backgrounds, then clears them from the cache
That said, depending on your workflow this approach may not be much better than simply using a time trigger to change the cells directly.