Skip to content

Commit

Permalink
Initialize main thread to MTA by default in NativeAOT (#73659)
Browse files Browse the repository at this point in the history
  • Loading branch information
elinor-fung authored Aug 10, 2022
1 parent a3fb0d3 commit 44d0cfe
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public override MethodIL EmitIL()
codeStream.Emit(ILOpcode.call, emitter.NewToken(method));
}
}

MetadataType startup = Context.GetOptionalHelperType("StartupCodeHelpers");

// Initialize command line args if the class library supports this
Expand Down Expand Up @@ -110,8 +110,9 @@ public override MethodIL EmitIL()
codeStream.EmitLdc((int)System.Threading.ApartmentState.STA);
codeStream.Emit(ILOpcode.call, emitter.NewToken(initApartmentState));
}
if (_mainMethod.WrappedMethod.HasCustomAttribute("System", "MTAThreadAttribute"))
else
{
// Initialize to MTA by default
codeStream.EmitLdc((int)System.Threading.ApartmentState.MTA);
codeStream.Emit(ILOpcode.call, emitter.NewToken(initApartmentState));
}
Expand Down

0 comments on commit 44d0cfe

Please sign in to comment.