WriteAll to filestream async
Monkey Forums/Monkey Beginners/WriteAll to filestream async
| ||
Hello! Is here any possibility to write data to file asynchronously? I am writing a little server using tcpasync. It works fine, but I dont want to break main loop on saving some data to server's hdd. What can you suggest? |
| ||
Here is a working example I just wrote for you: |
| ||
There are a few things to note: Monkeys Garbage Collector does not like creating object (no new XYZ, strings work when using StrDup) on a different thread than the mainthread. Also, all methods that the are called by the thread need to end with __UNSAFE__ or need to be defined as extern. The class you see at the bottom is just in copy of the regular filestream with the name of write changed to unsafe. |
| ||
Wow! Thank you! Very nice stuff! |