@@ -667,6 +667,9 @@ public unsafe static void SetValueInternalPtr(string cvarName, nint value) {
667667 private unsafe static delegate * unmanaged< byte * , byte * , byte > _SetValueAsString ;
668668
669669 public unsafe static bool SetValueAsString ( string cvarName , string value ) {
670+ if ( Thread . CurrentThread . ManagedThreadId != _MainThreadID ) {
671+ throw new InvalidOperationException ( "This method can only be called from the main thread." ) ;
672+ }
670673 var pool = ArrayPool < byte > . Shared ;
671674 var cvarNameLength = Encoding . UTF8 . GetByteCount ( cvarName ) ;
672675 var cvarNameBuffer = pool . Rent ( cvarNameLength + 1 ) ;
@@ -710,6 +713,9 @@ public unsafe static string GetValueAsString(string cvarName) {
710713 private unsafe static delegate * unmanaged< byte * , byte * , byte > _SetDefaultValueAsString ;
711714
712715 public unsafe static bool SetDefaultValueAsString ( string cvarName , string value ) {
716+ if ( Thread . CurrentThread . ManagedThreadId != _MainThreadID ) {
717+ throw new InvalidOperationException ( "This method can only be called from the main thread." ) ;
718+ }
713719 var pool = ArrayPool < byte > . Shared ;
714720 var cvarNameLength = Encoding . UTF8 . GetByteCount ( cvarName ) ;
715721 var cvarNameBuffer = pool . Rent ( cvarNameLength + 1 ) ;
@@ -753,6 +759,9 @@ public unsafe static string GetDefaultValueAsString(string cvarName) {
753759 private unsafe static delegate * unmanaged< byte * , byte * , byte > _SetMinValueAsString ;
754760
755761 public unsafe static bool SetMinValueAsString ( string cvarName , string value ) {
762+ if ( Thread . CurrentThread . ManagedThreadId != _MainThreadID ) {
763+ throw new InvalidOperationException ( "This method can only be called from the main thread." ) ;
764+ }
756765 var pool = ArrayPool < byte > . Shared ;
757766 var cvarNameLength = Encoding . UTF8 . GetByteCount ( cvarName ) ;
758767 var cvarNameBuffer = pool . Rent ( cvarNameLength + 1 ) ;
@@ -796,6 +805,9 @@ public unsafe static string GetMinValueAsString(string cvarName) {
796805 private unsafe static delegate * unmanaged< byte * , byte * , byte > _SetMaxValueAsString ;
797806
798807 public unsafe static bool SetMaxValueAsString ( string cvarName , string value ) {
808+ if ( Thread . CurrentThread . ManagedThreadId != _MainThreadID ) {
809+ throw new InvalidOperationException ( "This method can only be called from the main thread." ) ;
810+ }
799811 var pool = ArrayPool < byte > . Shared ;
800812 var cvarNameLength = Encoding . UTF8 . GetByteCount ( cvarName ) ;
801813 var cvarNameBuffer = pool . Rent ( cvarNameLength + 1 ) ;
@@ -839,6 +851,9 @@ public unsafe static string GetMaxValueAsString(string cvarName) {
839851 private unsafe static delegate * unmanaged< byte * , byte * , void > _SetValueInternalAsString ;
840852
841853 public unsafe static void SetValueInternalAsString ( string cvarName , string value ) {
854+ if ( Thread . CurrentThread . ManagedThreadId != _MainThreadID ) {
855+ throw new InvalidOperationException ( "This method can only be called from the main thread." ) ;
856+ }
842857 var pool = ArrayPool < byte > . Shared ;
843858 var cvarNameLength = Encoding . UTF8 . GetByteCount ( cvarName ) ;
844859 var cvarNameBuffer = pool . Rent ( cvarNameLength + 1 ) ;
0 commit comments