The testcode throws the following exception when entering thread.sleep()
after a forced garbage collector:
#### Exception System.Exception - CLR_E_WRONG_TYPE (3) ####
#### Microsoft.SPOT.Hardware.Port::Dispose [IP: 0000] ####
#### Microsoft.SPOT.Hardware.NativeEventDispatcher::Finalize [IP: 0005]
####
An unhandled exception of type 'System.Exception' occurred in
Microsoft.SPOT.Hardware.dll
public void DeviceGarbageCollectorTest()
{
try
{
//calling slave method
DeviceGarbageCollectorTest_Slave();
//the object testPort will now dispose
Debug.GC(true);
//now CLR_E_WRONG_TYPE will be thrown
Thread.Sleep(1000);
}
catch
{
Debug.Print("exception was thrown!");
}
}
private void DeviceGarbageCollectorTest_Slave()
{
//Reserve a Pin
Port.ReservePin(Cpu.Pin.GPIO_Pin14, true);
try
{
//try to create a OutputPort Object using the same pin
//OutputPort testPort = new OutputPort(Cpu.Pin.GPIO_Pin14,
true);
}
catch
{
//CLR_E_PIN_UNAVAILABLE will be thrown, everything seems to
be alright
}
}
----------------
This post is a suggestion for Microsoft, and Microsoft responds to the
suggestions with the most votes. To vote for this suggestion, click the "I
Agree" button in the message pane. If you do not see the button, follow this
link to open the suggestion in the Microsoft Web-based Newsreader and then
click "I Agree" in the message pane.