I wrote:
LocalNotification localNotification = new LocalNotification();
localNotification.setId("Gratitudine");
localNotification.setAlertTitle("Pratica della Gratitudine");
localNotification.setAlertBody("Leggi e ripeti interiormente");
localNotification.setAlertSound("/notification_sound_bell.mp3");
// alert sound file name must begin with notification_sound
Display.getInstance().scheduleLocalNotification(localNotification,
System.currentTimeMillis() + 60 * 1000, // first notification
LocalNotification.REPEAT_MINUTE // Whether to repeat and what frequency
);
It works.
What is a correct way to repeat the notification every ten minutes? The only available options are: REPEAT_NONE, REPEAT_MINUTE, REPEAT_HOUR, REPEAT_DAY, REPEAT_WEEK.
Same question for any arbitrary number of minutes (for example 4 or 13).
Thank you
According to the documentation it doesn't seem to be possible. You can only get it to repeat every minute. To do what you want you may need to setup additional notifications at the intervals. This means that if you want to cancel them you will need to do that when the user clicks on the notification and opens the app, or on some other event.
Related
private System.Timers.Timer timerSys = new System.Timers.Timer();
ticks are set to start at the beginning of each multiple of 5 seconds
entry exit
10:5:00.146 10:5:00.205
10:5:05.129 10:5:05.177
10:5:10.136 10:5:10.192
10:5:15.140 10:5:15.189
10:5:20.144 10:5:20.204
amd then a delay of 28 second
note that Windows 10 compensates for missing ticks
by firing them at close intervals
10:5:48.612 10:5:48.692
10:5:48.695 10:5:48.745
10:5:48.748 10:5:48.789
10:5:48.792 10:5:49.90
10:5:43.93 10:5:49.131
and another delay of 27 seconds
again Windows 10 crams ticks to compensate
but this time there is an even inside the second tick
that lasts about 28 seconds that makes the tick very long
10:6:16.639 10:6:16.878
this one is very long
10:6:16.883 10:6:42.980
10:6:42.984 10:6:43.236
10:6:43.241 10:6:43.321
10:6:43.326 10:6:43.479
The PC is running just two applications that I wrote.
They communicate via files and also via SQL tables.
This event happens maybe once every two months.
Questions:
What could be happening?
Is there a way to create a log file of all processes over time
My applications keep tabs of the time down to milliseconds.
So if there were a way of logging processes, I could match.
Alternately is there a way for my app to know what the OS is doing.
I am new to the GCP world. I have to check whether my batchSetting for publishing message to pub sub really work or not. This is the batch setting:
private BatchingSettings getBatchingSettings() {
long requestBytesThreshold = 10000L;
long messageCountBatchSize = 100L;
Duration publishDelayThreshold = Duration.ofMillis(2000);
BatchingSettings batchingSettings = BatchingSettings.newBuilder()
.setElementCountThreshold(messageCountBatchSize)
.setRequestByteThreshold(requestBytesThreshold)
.setDelayThreshold(publishDelayThreshold)
.build();
return batchingSettings;
}
I have to check whether pub sub publishes the message in batch of 100 or not.
Is there any way to check how many messages really published by per batch?
As it is explained in the documentation you can monitor Pub/Sub in Cloud monitoring. When you follow the link you will go to the Cloud Monitoring on your project.
In Metrics explorer its possible to create a metric of flowing configuration:
Recourse type: Cloud Pub/Sub Topic
Metric: Publish message operations
Group by: topic_id
Aggergator: sum
Minimum alignment period: 1 minutes
In "SHOW ADVANCED OPTIONS" set:
Aligner: sum
If you search such chart in some dashboard you can check the count of published massages there. Now just submit separate testing batch and wait for peak on the chart. When you hoover on the chart line you will see the number of massages in particular time period. Sometimes it will be decided into more parts, but in such small batch like 100 it should be no more than 2. So its enough to add 2 numbers.
Of course you can create more sophisticated metrics. This is just example.
I am developing an app on React where countdown timers are the main component (at the same time there can be 10-20 timers on the page). From the server I get: how long the timer should go and how much is left in seconds. Then every second I recount how much is left. The source data is stored in redux, and calculated in the component local state.
These timers should show the same values for every user.
The problem is when I duplicate the tabs in the browser, the api request does not occur, respectively, the timers in a new tab are rolled back to the old state.
Updating data every second in redux seems to me not to be the best option, but I don’t see others yet.
You said that the server sends you the remaining time in seconds. So you can calculate on the client side when the countdown should end in client time. You can store that in local storage. When a new tab is opened you can use that value to initialize your timer.
It does not require the client time to be correct or in sync with the server time as all tabs share the same (possibly wrong) client time. You are only interested in the difference in seconds between the current client time and the client time you saved to correctly initialize your timer.
A solution to calculate it could roughly look like this:
// when receiving the remaining seconds in the first tab
const onReceivedRemaining = (remaining) => {
const now = new Date(); // current client time
now.setSeconds(now.getSeconds() + remaining); // timer end in client time
localStorage.set('elapsing', JSON.stringify(now));
}
// when initializing the timer in a second tab
const getInitial = () => {
const elapsing_string = localStorage.get('elapsing');
if (!elapsing_string) return null;
const now = new Date();
const elapsing = Date.parse(elapsing_string);
return (elapsing - now) / 1000; // remaining time in seconds
}
How can I set up a timer when playing a log file. The timer should start when the log file starts. At a certain event the timer should be printed out in the write window.
There are som built in functions in CAPL do you know how they work?
For example TimeToElapse
Thanks
First insert a replay block in your measurement configuration. In the replay block select your log file and uncheck "Start replay on measurement start" if you want to start the replay from CAPL code.
In the following example I bound the procedure to two on key events:
on key 'a' {
replayStart("ReplayBlockName");
setTimer(mytimer, mytime);
}
on timer mytimer {
// on timer event needed so that setTimer function works properly
}
on key 's' {
write("time to elapse = %d", timeToElapse(mytimer));
}
So basically hit the key 'a' during measurement and afterwards key 's' to see how much time is left. Keep in mind that the output is dependent on your timer. When declaring a regular timer, timeToElapse returns whole seconds. When declaring a msTimer, timeToElapse returns milli seconds.
Is there a way to run a task in rust, a thread at best, at a specific time or in an interval again and again?
So that I can run my function every 5 minutes or every day at 12 o'clock.
In Java there is the TimerTask, so I'm searching for something like that.
You can use Timer::periodic to create a channel that gets sent a message at regular intervals, e.g.
use std::old_io::Timer;
let mut timer = Timer::new().unwrap();
let ticks = timer.periodic(Duration::minutes(5));
for _ in ticks.iter() {
your_function();
}
Receiver::iter blocks, waiting for the next message, and those messages are 5 minutes apart, so the body of the for loop is run at those regular intervals. NB. this will use a whole thread for that single function, but I believe one can generalise to any fixed number of functions with different intervals by creating multiple timer channels and using select! to work out which function should execute next.
I'm fairly sure that running every day at a specified time, correctly, isn't possible with the current standard library. E.g. using a simple Timer::periodic(Duration::days(1)) won't handle the system clock changing, e.g. when the user moves timezones, or goes in/out of daylight savings.
For the latest Rust nightly-version:
use std::old_io::Timer;
use std::time::Duration;
let mut timer1 = Timer::new().unwrap();
let mut timer2 = Timer::new().unwrap();
let tick1 = timer1.periodic(Duration::seconds(1));
let tick2 = timer2.periodic(Duration::seconds(3));
loop {
select! {
_ = tick1.recv() => do_something1(),
_ = tick2.recv() => do_something2()
}
}