Is there a way to trigger provideinlinecompletionitems after certain debounce time (say 300ms) instead of every keystroke - vscode-extensions

provideinlinecompletionitems of a vscode extension that provides completions is being triggered on every keystroke. Is there a way to configure the trigger time after certain debounce time (say 300ms) instead of every keystroke?

Related

Event triggered Variable in AnyLogic

I want to trigger a variable from false to true when my event is done. Is there like an "on Exit" action area for events? There is only "action" and the variable does not change. Or is there a best way to change my variable?
There is no OnExit code field for Event, as these code fields are only used on process modelling blocks (such as Source, Delay, .....). These blocks typically have a flow through them and give the user the opportunity to trigger actions at certain points of time in this flow.
An Event, on the other hand, is not part of a process flow. It is a simple trigger, like an egg-timer, to execute a piece of code. This piece of code is executed at the exact time when the event triggers, while the simulation time is paused. So when you want something to happen after the code you defined in your Event, just add it at the end of the code.
I attached a screenshot to show you how it could look like to change a variable by an Event:

How to Repeat Saving my Powerpoint file every 5 minutes?

I've been wanting to write a macro to automatically save my powerpoint file every 5 minutes. Can anyone help?
I know there's an auto-save built-in but that's only good for auto recover. I'm attempting to have this ppt being saved every 5 mins so that other users using it at the same time will see the updates come in (using Office 365).
Thanks!
I don't think you'll be able to do this with a simple macro, but you might be able to make it work with an add-in.
The add-in would:
Trap events, specifically the SelectionChanged event.
Every time the event fires, the event handling code compares the current time to the time it last fired (stored in a static variable).
If more than x minutes have elapsed since the event last fired, saves the presentation and resets the last-fired time.
If the event never fires during a session, it means that nothing changed, so no real reason to save.
A further refinement: before or after checking the time difference, check the presentation's .Saved property. If True, then nothing has changed in the presentation, so again, no reason to save.
I could be wrong, but most answers I've seen regarding saving in intervals use the OnTime method. This isn't actually available in PowerPoint, so I'm not actually sure that what you're wanting to do is possible.

How to update a NSTextField Value during an action?

I am running a lengthly task in an Action and I would like to have a display of where I am at. For that I created a Text Field and I tried it with setStringValue:
[textField setStingValue: [NSSting stringWithFormat:#"%ld",currentValue]]
The code works but unfortunately it is not updating the NSTextField after every iteration but rather when the whole Action is done.
What am I doing wrong?
This is because applications with the Cocoa framework use an event loop to perform operations, and events occur in a completely serial fashion.
An event is basically any kind of action that the framework designer could not predict or found convenient to have run in a delayed manner. Since you can't predict when clicks will be performed, they need to be considered events; and for efficiency reasons (since you don't want to repaint a component multiple times if you don't need to), the repaint actions are events too.
Your action runs in response to a user event (for instance, a click on a button is an event) and therefore blocks all other events waiting in the queue until it's complete. However, components are repainted in response to a different, framework-triggered event, and as such the text field must wait until your action completes to repaint itself. This is why you cannot visually change the value of a text field from inside an action.
In order to notify your user of the progress of your task, you'll need to run it on a different thread. There's a lot to say about threads, so you should probably read some about them. I'm also sure that there are plenty of examples of how to run a long action in a background thread and update the UI accordingly for Cocoa all over the Internet.
When you click on a UI component, and it enters the Action block, the code is running on the main thread, the same thread that is painting the UI. If you run a long running operation in that block, it isn't going to paint until you are done because it is busy doing whatever you have it doing - you have hijacked the paint thread.
As said elsewhere, you need to spawn another thread, and then have the new thread perform the long running operation, and occasionally send messages to have the UI be updated by the main thread.
As a next step, go read the Apple documentation on NSThread, specifically:
+ (void)detachNewThreadSelector:(SEL)aSelector toTarget:(id)aTarget withObject:(id)anArgument
Be aware that threading is a non-trivial domain area, and be ready for some wierd behavior if you aren't careful.

Popup window / message for remaining time

I have several froms in my application. When application starts, a timer starts for 30 minutes.
I want to show the remaining time using a popup window, message or whatever, on whichever form the user is at that time.
Please advise how to do it.
Thanks
Furqan
The timer objects in the .net framework do not give access to the time already elapsed or remaining.
However when your application starts you will can create and start a stop watch.
private _sw as System.Diagnostics.Stopwatch = System.Diagnostics.Stopwatch.StartNew()
At any time you can then call the following code which you can subtract from your 30 minutes
_sw.Elapsed.TotalSeconds
To show this time constantly on a form you may need a second timer to update the screen that queries this value.

Best way to save status of dynamic web interface

Basically in my website I have a sidebar with a stack of boxes; each box can be collapsed or expanded by the user. I need to save the status of each box for the currently logged in user.
I don't want to use cookies because if an user changes browser or computer, all the boxes will go to the default status.
Should I save this information on the database making a query every time the user collapses/expands a box? How would you handle this? Thanks.
Edit: What if an user clicks on the toggle button repeatedly, like ten times in two seconds, just because he enjoys the boxes' animation? He will make ten queries in two seconds. So maybe the question should be: when should I save this data?
Call a (client-side) "changed" function every time a box changes.
Keep two items of (client-side) state: the time the last update to the server was sent and whether a timer has been set.
Write a (client-side) "update" function that sends the update and updates the state to mark that the last update was just now.
When the changed function is called: if a timer is set, then return immediately; if an update has never been sent or the last update was sent more than ten seconds ago, then call the update function and return. Otherwise set a timer to send the update after ten seconds.
The timer callback should simply clear the timer flag and call the update function.
Also on an unload event check if a timer was set and if it was then clear the timer and call the timer callback function.
So the result is that you send the update immediately except when the user is flapping, in which case you only send an update every ten seconds at most.
There might be some cases where you lose an update, but this is likely to only happen if the user was playing with the toggling and then closed the page before the timer fired, in which case he probably won't notice anyway.
If you need to persist these options from multiple computers you will need some form of server side storage.
This could be database or flat file. The choice depends on what you have available, skill set, and the need to scale. If you are going to have just a few users, a flat file may be your best choice.