# Can't set realtime thread priority=99: Operation not permitted. When using the c# wrapper

**URL:** <https://rpi-rgb-led-matrix.discourse.group/t/cant-set-realtime-thread-priority-99-operation-not-permitted-when-using-the-c-wrapper/668>\
**Category:** Uncategorized\
**Created:** [April 28, 2023, 2:03pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/cant-set-realtime-thread-priority-99-operation-not-permitted-when-using-the-c-wrapper/668 "2023-04-28T14:03:08Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marcokreeft](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@marcokreeft](https://rpi-rgb-led-matrix.discourse.group/u/marcokreeft)\
**Post date:** [April 28, 2023, 2:03pm UTC](https://rpi-rgb-led-matrix.discourse.group/t/cant-set-realtime-thread-priority-99-operation-not-permitted-when-using-the-c-wrapper/668/1 "2023-04-28T14:03:08Z")

</div>

I’m using the C# wrapper with a web api in .net 7. The first image I want to show on my pixel display with the wrapper works. But every image after that gives the following error

```auto
Can't set realtime thread priority=99: Operation not permitted.
        You are probably not running as root ?
        This will seriously mess with color stability and flicker
        of the matrix. Please run as `root` (e.g. by invoking this
        program with `sudo`), or setting the capability on this
        binary by calling
        sudo setcap 'cap_sys_nice=eip' /home/sharevalue/pixelsharp/bin/Debug/net7.0/pixelsharp

```

Now, I have to run the app with sudo dotnet run, otherwise it wont work.  
Does anyone know what to do to fix my issue?

---

<div class="post-metadata">

**Author:** ![marcmerlin](https://yyz2.discourse-cdn.com/free1/user_avatar/rpi-rgb-led-matrix.discourse.group/marcmerlin/32/40_2.png) [@marcmerlin](https://rpi-rgb-led-matrix.discourse.group/u/marcmerlin)\
**Post date:** [May 2, 2023, 3:23am UTC](https://rpi-rgb-led-matrix.discourse.group/t/cant-set-realtime-thread-priority-99-operation-not-permitted-when-using-the-c-wrapper/668/2 "2023-05-02T03:23:11Z")

</div>

> [@marcokreeft](#):
>
> ```auto
> sudo setcap 'cap_sys_nice=eip' /home/sharevalue/pixelsharp/bin/Debug/net7.0/pixelsharp
> 
> ```

did you do what the message said?  
sudo setcap ‘cap\_sys\_nice=eip’ /home/sharevalue/pixelsharp/bin/Debug/net7.0/pixelsharp

---

<div class="post-metadata">

**Author:** ![marcokreeft](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@marcokreeft](https://rpi-rgb-led-matrix.discourse.group/u/marcokreeft)\
**Post date:** [May 2, 2023, 5:34am UTC](https://rpi-rgb-led-matrix.discourse.group/t/cant-set-realtime-thread-priority-99-operation-not-permitted-when-using-the-c-wrapper/668/3 "2023-05-02T05:34:10Z")

</div>

Yes but the problem is that you have to set that with every request. But I fixed it now by using a Singleton pattern 🙂

---

<div class="post-metadata">

**Author:** ![hhgm](https://avatars.discourse-cdn.com/v4/letter/h/f08c70/32.png) [@hhgm](https://rpi-rgb-led-matrix.discourse.group/u/hhgm)\
**Post date:** [September 5, 2024, 5:34am UTC](https://rpi-rgb-led-matrix.discourse.group/t/cant-set-realtime-thread-priority-99-operation-not-permitted-when-using-the-c-wrapper/668/4 "2024-09-05T05:34:31Z")

</div>

Sorry to highjack this… I am trying to get started on this using the C# bindings… but I am having issues just getting the base dll to work correctly… do you have any pointer on how to do it?
