Ich sags mal so: rein theoretisch musst du diesen Code nur adaptieren:

https://www.codeproject.com/Articles...tion-in-Csharp