# Motoko equivalent of C# Task.Delay()

**URL:** <https://forum.dfinity.org/t/motoko-equivalent-of-c-task-delay/16635>\
**Category:** Developers\
**Created:** [November 17, 2022, 2:25am UTC](https://forum.dfinity.org/t/motoko-equivalent-of-c-task-delay/16635 "2022-11-17T02:25:42Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AVOlight](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/avolight/32/3197_2.png) [@AVOlight](https://forum.dfinity.org/u/AVOlight)\
**Post date:** [November 17, 2022, 2:25am UTC](https://forum.dfinity.org/t/motoko-equivalent-of-c-task-delay/16635/1 "2022-11-17T02:25:42Z")

</div>

Is this complete [Time | Internet Computer Home](https://internetcomputer.org/docs/current/references/motoko-ref/Time)

---

<div class="post-metadata">

**Author:** ![skilesare](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/skilesare/32/5609_2.png) [@skilesare](https://forum.dfinity.org/u/skilesare)\
**Post date:** [November 17, 2022, 2:30am UTC](https://forum.dfinity.org/t/motoko-equivalent-of-c-task-delay/16635/2 "2022-11-17T02:30:45Z")

</div>

I don’t think the timers api has been released to motoko yet. You can keep up with updates at [Heartbeat improvements / Timers [Community Consideration]](https://forum.dfinity.org/t/heartbeat-improvements-timers-community-consideration/14201)

---

<div class="post-metadata">

**Author:** ![AVOlight](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/avolight/32/3197_2.png) [@AVOlight](https://forum.dfinity.org/u/AVOlight)\
**Post date:** [November 17, 2022, 2:47am UTC](https://forum.dfinity.org/t/motoko-equivalent-of-c-task-delay/16635/3 "2022-11-17T02:47:13Z")

</div>

Thanks for the link 🙂

skimming over

> **[GitHub - dfinity/motoko: Simple high-level language for writing Internet...](https://github.com/dfinity/motoko)**
>
> Simple high-level language for writing Internet Computer canisters - GitHub - dfinity/motoko: Simple high-level language for writing Internet Computer canisters

> **[examples/motoko at master · dfinity/examples](https://github.com/dfinity/examples/tree/master/motoko)**
>
> master/motoko

didn’t see anything on timers, sleep or delay 🙁

in my case I guess I can just query an external canister for a short delay

---

<div class="post-metadata">

**Author:** ![icme](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/icme/32/4327_2.png) [@icme](https://forum.dfinity.org/u/icme)\
**Post date:** [November 17, 2022, 6:22am UTC](https://forum.dfinity.org/t/motoko-equivalent-of-c-task-delay/16635/4 "2022-11-17T06:22:34Z")

</div>

> [@AVOlight](#):
>
> in my case I guess I can just query an external canister for a short delay

That’s not a bad idea, but you currently can’t make inter-canister query calls, only inter-canister update calls are supported.

Also, keep in mind that while an inter-canister update call is in-flight it might be blocking other update messages from being processed, so you may not get the behavior you’re looking for.

It might be helpful if you provide an MVP of the “delay” functionality that you’re looking for in the context of a use case, or a code sample (maybe on the [Motoko Playground](https://m7sm4-2iaaa-aaaab-qabra-cai.raw.ic0.app/)).

---

<div class="post-metadata">

**Author:** ![AVOlight](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/avolight/32/3197_2.png) [@AVOlight](https://forum.dfinity.org/u/AVOlight)\
**Post date:** [November 17, 2022, 7:23pm UTC](https://forum.dfinity.org/t/motoko-equivalent-of-c-task-delay/16635/5 "2022-11-17T19:23:12Z")

</div>

this seems to be working for me

```auto
let external_canister = actor "canister_id" : actor {
        get_location: query () -> async { x : Int; y : Int };
    };

```

having a convenient delay function is great for prototyping anything async

---

<div class="post-metadata">

**Author:** ![AVOlight](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/avolight/32/3197_2.png) [@AVOlight](https://forum.dfinity.org/u/AVOlight)\
**Post date:** [March 17, 2023, 1:10am UTC](https://forum.dfinity.org/t/motoko-equivalent-of-c-task-delay/16635/6 "2023-03-17T01:10:57Z")

</div>

currently using

```auto
let raw_rand = (actor "aaaaa-aa" : actor { raw_rand : () -> async Blob }).raw_rand;
for (_ in Iter.range(0, count))
  ignore await raw_rand();

```

any ideas on how to use  
`Timer.setTimer`  
instead 🤔

while keeping the same local scope like above
