# Use save(); in the background

**URL:** <https://discourse.processing.org/t/use-save-in-the-background/40446>\
**Category:** Beginners\
**Created:** [January 4, 2023, 4:49pm UTC](https://discourse.processing.org/t/use-save-in-the-background/40446 "2023-01-04T16:49:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lissie](https://avatars.discourse-cdn.com/v4/letter/l/f19dbf/32.png) [@Lissie](https://discourse.processing.org/u/Lissie)\
**Post date:** [January 4, 2023, 4:49pm UTC](https://discourse.processing.org/t/use-save-in-the-background/40446/1 "2023-01-04T16:49:49Z")

</div>

When i want to use the save function, the programm lags for a few milliseconds, can i make it so it does it in the background?

---

<div class="post-metadata">

**Author:** ![mnse](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/mnse/32/16520_2.png) [@mnse](https://discourse.processing.org/u/mnse)\
**Post date:** [January 4, 2023, 5:58pm UTC](https://discourse.processing.org/t/use-save-in-the-background/40446/2 "2023-01-04T17:58:20Z")

</div>

Hi @Lissie,

What exactly do you try to achieve?  
The save or saveframe functions are meant to save the current window content, resp graphics buffer to a image file. Usually this is used to save a screenshot for the first or to save all the frames for the latter to ie. create a video from the frames. Both shouldn’t be time critical actions so the lagging shouldn’t be a problem…

Cheers  
— mnse

---

<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:** [January 4, 2023, 6:47pm UTC](https://discourse.processing.org/t/use-save-in-the-background/40446/3 "2023-01-04T18:47:46Z")

</div>

`hint(ENABLE_ASYNC_SAVEFRAME);`

> **[hint() / Reference](https://processing.org/reference/hint_.html)**
>
> This function is used to enable or disable special features that control how graphics are drawn. In the course of developing Processing, we had to make hard decisions about tradeoffs between performan…

---

<div class="post-metadata">

**Author:** ![Lissie](https://avatars.discourse-cdn.com/v4/letter/l/f19dbf/32.png) [@Lissie](https://discourse.processing.org/u/Lissie)\
**Post date:** [January 4, 2023, 6:57pm UTC](https://discourse.processing.org/t/use-save-in-the-background/40446/4 "2023-01-04T18:57:48Z")

</div>

im making a programm with an undo function. it needs to save an image and while its saving still track mouse movement & check variables!  
Cheers

---

<div class="post-metadata">

**Author:** ![Chrisir](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/chrisir/32/45_2.png) [@Chrisir](https://discourse.processing.org/u/Chrisir)\
**Post date:** [January 4, 2023, 8:54pm UTC](https://discourse.processing.org/t/use-save-in-the-background/40446/5 "2023-01-04T20:54:52Z")

</div>

Two thoughts:

- instead of save to Hard Drive you could save to a PGraphics with get() - might be faster. Then you can undo from there. You could even store in an array.
- you could use thread() for a new process/thread

---

<div class="post-metadata">

**Author:** ![Lissie](https://avatars.discourse-cdn.com/v4/letter/l/f19dbf/32.png) [@Lissie](https://discourse.processing.org/u/Lissie)\
**Post date:** [January 5, 2023, 4:43pm UTC](https://discourse.processing.org/t/use-save-in-the-background/40446/6 "2023-01-05T16:43:13Z")

</div>

yep that worked! thank man!  
I used thread. if you want to use it in a class make a “public void yourthread()” and in the class write “thread(“yourthread”);” if you want to use variables or PImages or anything that only exists in the class, make a getter method (you dont need to make a new variable in the main part, just use “theclass.getVariableOne()” in for example “rect(theclass.getVariableOne(),10,10,10);” i hope this helps all of you who want to make a drawing app, text editing app or anything!
