I have a .NET 4.0 Windows Service that hosts components. Our project lead says that when calling methods on certain components, that performance is slow. He suspects that it may be an STA component that incurs this performance penalty.
To test this theory, I have been asked to create a STA component with one method accepts an integer and returns the integer multiplied by two. This component will be hosted in the service and tests will be run.
Can something like this be created in C# or would it be necessary to create it in C++?
If possible, could you include some code?
EDIT: (code based on Han's suggestion)
using System.Runtime.InteropServices;
namespace STADemo
{
[ComVisible(true)]
public class STAClass
{
public int Calculate(int value)
{
return 2*value;
}
}
}