I have a slideshow application where i want to wait a certain amount of seconds, then show my front page, then wait again, then show next page, and so on. My problem is that when i use Thread.Sleep in between, the UI arent updated, it just sits there waiting and i only see my last control (after the full amount of time has passed (i.e all the sleeps). Any solutions for doing this?
Thread.Sleep(1000);
ChangeContent(new FrontPage());
Thread.Sleep(5000);
ChangeContent(new HtmlPage());
Pre WPF i would just use the Application.DoEvents.
Use a DispatcherTimer.
Related
I'm working on a C application using Gtk for the GUI. We have custom slider widgets connected to the "mouse scrolled" event with a callback function. The problem is each scrolling increment will trigger the callback once, which updates a parameter and refreshes a computationaly-expensive rendering. So, when the user scrolls more than once, the GUI freezes until all scrolls are processed individually in sequence.
I want to have the multiple unit scrolling increments recorded as one flat increment, such that the expensive rendering is started only once the user is done scrolling, so we only record all increments until the scrolling is finished and then we update the parameter and refresh the rendering.
My first idea was to have the "mouse scrolled" callback emit some "update" signal and save :
the timestamp of the scroll event long t,
the number of scrolling increments int steps
Each new scrolling event would increment the steps counter and overwrite the timestamp.
Then, the "update" signal would be captured by a function that would wait for t + 0.5 s to actually save the slider value and trigger a new rendering. If the user performs a new scrolling during that time, the function would just keep waiting.
Is there a Gtk or C API to perform that kind of task ?
Using redux-toolkit, rxjs, redux-observable
I want to add a 1-second delay between the same action if they are within a short period of time.
A naive example:
if you click a button that displays a pop-up 10 times really quickly, then I want to only show all ten pop-ups but only one pop-up for a second before showing the next pop-up.
let's say the button dispatches an action. is there a way to observe the stream of actions coming in and add a delay?
In my webapp, I have a send dialogue box which sends the data to a selected email address. The issue is that the dialog box disappears after few seconds of clicking send button which makes the user click send button multiple times as a result of which same mail is sent multiple times.
What I think is that this can be a function of the speed of the DB (and probably the size of the data).
If it takes several second to receive confirmation then you must reflect that in the UI, by putting up a "wait" cursor, disabling the "Send" button, possibly dimming the dialog box etc. There's nothing wrong with taking a few seconds as long as you make sure the user is aware and cannot click Send a second time
Even if you expect the operation to be nearly instantaneous in most cases, you STILL must reflect the possibility of a delay in the UI. That's just a fundamental UI design principle.
Is there a way to do something like this?
Background:
I have a button click. When the button is clicked I try to show a "loading" message, run a bunch of code that does some UI work and then dismiss the "loading" message. It takes anywhere from a few seconds to 20 seconds usually. At the moment the loading message doesn't show at all and the UI freezes until the code in my button click is done.
I've read about Background Worker and dispatcher, but haven't been able to get it to work. I'm not sure if it's because the code in the button click calls all sorts of other code (including 3rd party stuff), but I haven't been able to get it to run correctly. It all still works, but it still freezes the UI and the loading message doesn't appear.
So, I am wondering if there is another way around this. Is it possible to set it up so that on the button click I only show the loading message and then a second or so later fire another event that executes my long running process? That way the UI will still freeze for some seconds, but at least it will show a "loading" message.
You should be able to do this with a Dispatcher.BeginInvoke call.
private void ButtonClick(object sender, EventArgs e)
{
ShowMyLoadingMessage(); // your code, not sure what it is
Dispatcher.BeginInvoke(() =>
{
CallMyLongRunningCode(); // again, not sure what this is
HideMyLoadingMessage();
}
}
I don't believe this is the best solution since it is running on the UI thread, but it should do what you are asking.
What is the long running code doing that takes 20 seconds?
I am creating a DotNetNuke module which is a simple text field which the value is then passed to stored procedure and results bound to grid.
When I first load the page, I can enter a term - hit 'search' button and I can see in debug that the buttons click is processed - and results are returned.
However the next time I press the button there is no postback? Even my breakpoint on Page_Load doesn't hit?
What gives?
DNN is working to improve this. There are some hopeful plans underway to change the way dynamic modules are cache. For the time being, you do not want to cache modules that have dynamic content.
Yikes! I set the DefaultCacheTime to 0 and now it's working fine!