I have an "Update" function in which the end isn't executed, then I use the function "Console.WriteLine" to know where the function is interrupted. Here is the Udate function:
async Task Update()
{
count++;
try
{
List<string> cmds = new List<string>();
if (Ev3Messaging.IsConnected())
{
Tuple<string, string> response = null;
Console.WriteLine("Test1"); // Displayed
try
{
response = await Ev3Messaging.ReceiveText(true);
}
catch(Exception ex)
{
Console.WriteLine(ex.Source + ": " + ex.Message); // Not displayed
}
Console.WriteLine("Test2"); // Not displayed
while (response != null)
{
Console.WriteLine("Test2: " + response.Item2);
string[] list = response.Item2.Split(';');
foreach (string cmd in list)
cmds.Add(cmd);
response = await Ev3Messaging.ReceiveText(false);
}
}
Canvas canvas = _screenSV.Holder.LockCanvas();
if (canvas != null)
{
foreach (string cmd in cmds)
ExecuteCommand(cmd, canvas);
_screenSV.Holder.UnlockCanvasAndPost(canvas);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Source + ": " + ex.Message);
}
}
The Update function is called each 100ms by the following code:
var timer = new System.Threading.Timer((e) =>
{
RunOnUiThread(async () => await Update());
}, null, 0, 100);
It displays "Test1", but it displays neither the exception (no problem in the "EV3Messaging.ReceiveText" function), nor "Test2" (function interrupted before reaching "ShowAlert("Test2");" )
How is it possible ?
If you want me to post the "Ev3Messaging.ReceiveText" function, please ask me. I didn't post it since it is big enough, and I just want to know how is it possible to get this problem...
Thanks in advance.