# TimedEvents library problem

**URL:** <https://discourse.processing.org/t/timedevents-library-problem/13406>\
**Category:** Libraries\
**Created:** [August 15, 2019, 10:38pm UTC](https://discourse.processing.org/t/timedevents-library-problem/13406 "2019-08-15T22:38:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![aledante](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@aledante](https://discourse.processing.org/u/aledante)\
**Post date:** [August 15, 2019, 10:38pm UTC](https://discourse.processing.org/t/timedevents-library-problem/13406/1 "2019-08-15T22:38:07Z")

</div>

Hi everyone,

Excuse my poor english.  
I´m having problems with TimedEvents library. I can not get it to draw anything. Even examples doesn´t work. Nothing inside void onTimerEvent() draw anything.

```auto
import org.multiply.processing.TimedEventGenerator;

TimedEventGenerator ellipseTimedEventGenerator;

void setup() {
  size(400, 400);
  background(255);
  ellipseTimedEventGenerator = new TimedEventGenerator(this);
  ellipseTimedEventGenerator.setIntervalMs(1500);
}

void draw() {
  fill(20);
  ellipse(100, 100, 30, 30);
  // ellipse(random(width), random(height), random(100), random(100));
}
void onTimerEvent() {
  println("now", millis());
  fill(20);
  ellipse(random(width), random(height), random(100), random(100));
}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [August 15, 2019, 11:58pm UTC](https://discourse.processing.org/t/timedevents-library-problem/13406/2 "2019-08-15T23:58:21Z")

</div>

> [@aledante](#):
>
> Nothing inside `void` **onTimerEvent()** draws anything.

Place this statement at the beginning of **onTimerEvent()** callback:  
`println(Thread.currentThread());`

If it doesn’t log something like: Thread[Animation Thread,5,main].  
It means another Thread is executing that callback and we can’t “draw” anything there!

As a workaround, you can have some global `boolean` variable and set it `true` inside **onTimerEvent()**.

Inside **draw()**, keep checking that flag variable each iteration, so it knows when it has to “draw” what it was previously inside **onTimerEvent()**.

Of course after that, you’re gonna need to revert it back to `false`.

Take a look at the sketch link below for a similar example on how to do it:

> <https://gist.github.com/GoToLoop/ea4db8a8622e27541213da3c9a43ca21>

---

<div class="post-metadata">

**Author:** ![aledante](https://avatars.discourse-cdn.com/v4/letter/a/ad7895/32.png) [@aledante](https://discourse.processing.org/u/aledante)\
**Post date:** [August 16, 2019, 10:20pm UTC](https://discourse.processing.org/t/timedevents-library-problem/13406/3 "2019-08-16T22:20:57Z")

</div>

Yes! I did it just like that, but I thought I had done something wrong with TimedEvents library because it’s one of the official libraries and not even the examples work. The answer is “Thread[pool-1-thread-1,5,main]”.

Thanks! As always “un capo” or “un genio”:
