Hi,
Can anyone help me on this.
I am facing this weird issue, when I try to fetch some rows(row by row) from my dataset(dataframe in R). First few rows are fetched without any error but after say 4-5 rows I get some exception on a line which executed perfectly for first few rows.
I am executing following statement:
SomeRDotNetObject.Evaluate("Dataset1[rowindex , ]" ); // Dataset1 is the name of the dataset
for say rowindex= 1 to 4 this works but fails on rowindex=5. And C# application crashes with following exception:-
_System.Windows.Threading.DispatcherUnhandledExceptionEventHandler -METHOD :Invoke() -LINE :0
System.InvalidOperationException: Dispatcher processing has been suspended, but messages are still being processed.
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)_
Thanks
adabral
Comments: Here's my test case using the builtin mtcars dataset. I'm not seeing any problems. I'm hoping that you'll take the time to modify it to be closer to your setup. I chose to use databinding, but directly to the codebehind and not MVVM. I'm not creating any objects on the GUI thread, but I did try some dispatcher calls without issue using System; using System.ComponentModel; using System.Windows; using RDotNet; namespace RDotNetWPFTest { public partial class MainWindow : INotifyPropertyChanged { private readonly REngine _rEngine; public MainWindow() { InitializeComponent(); DataContext = this; _rEngine = REngine.GetInstance(); RowContents = "No Rows Fetched"; RowIndex = 0; OnPropertyChanged("RowContents"); OnPropertyChanged("RowIndex"); } public int RowIndex { get; private set; } public string RowContents { get; private set; } private void button_Click(object sender, RoutedEventArgs e) { SymbolicExpression se = null; try { se = _rEngine.Evaluate(string.Format("mtcars[{0}, ]", RowIndex)); // Dataset1 is the name of the dataset } catch (Exception) {} var rowdata = se.AsCharacter().ToArray(); RowIndex++; RowContents = string.Join(":", rowdata); OnPropertyChanged("RowIndex"); OnPropertyChanged("RowContents"); } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string propertyName = null) { var handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); } } } <Window x:Class="RDotNetWPFTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> <Grid> <Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="134,128,0,0" VerticalAlignment="Top" Width="75" Click="button_Click"/> <TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="134,93,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="328" Text="{Binding RowContents}"/> <TextBlock x:Name="rowIndex" HorizontalAlignment="Left" Margin="259,131,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="{Binding RowIndex}"/> </Grid> </Window>
Can anyone help me on this.
I am facing this weird issue, when I try to fetch some rows(row by row) from my dataset(dataframe in R). First few rows are fetched without any error but after say 4-5 rows I get some exception on a line which executed perfectly for first few rows.
I am executing following statement:
SomeRDotNetObject.Evaluate("Dataset1[rowindex , ]" ); // Dataset1 is the name of the dataset
for say rowindex= 1 to 4 this works but fails on rowindex=5. And C# application crashes with following exception:-
_System.Windows.Threading.DispatcherUnhandledExceptionEventHandler -METHOD :Invoke() -LINE :0
System.InvalidOperationException: Dispatcher processing has been suspended, but messages are still being processed.
at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at MS.Internal.Threading.ExceptionFilterHelper.TryCatchWhen(Object source, Delegate method, Object args, Int32 numArgs, Delegate catchHandler)_
Thanks
adabral
Comments: Here's my test case using the builtin mtcars dataset. I'm not seeing any problems. I'm hoping that you'll take the time to modify it to be closer to your setup. I chose to use databinding, but directly to the codebehind and not MVVM. I'm not creating any objects on the GUI thread, but I did try some dispatcher calls without issue using System; using System.ComponentModel; using System.Windows; using RDotNet; namespace RDotNetWPFTest { public partial class MainWindow : INotifyPropertyChanged { private readonly REngine _rEngine; public MainWindow() { InitializeComponent(); DataContext = this; _rEngine = REngine.GetInstance(); RowContents = "No Rows Fetched"; RowIndex = 0; OnPropertyChanged("RowContents"); OnPropertyChanged("RowIndex"); } public int RowIndex { get; private set; } public string RowContents { get; private set; } private void button_Click(object sender, RoutedEventArgs e) { SymbolicExpression se = null; try { se = _rEngine.Evaluate(string.Format("mtcars[{0}, ]", RowIndex)); // Dataset1 is the name of the dataset } catch (Exception) {} var rowdata = se.AsCharacter().ToArray(); RowIndex++; RowContents = string.Join(":", rowdata); OnPropertyChanged("RowIndex"); OnPropertyChanged("RowContents"); } public event PropertyChangedEventHandler PropertyChanged; private void OnPropertyChanged(string propertyName = null) { var handler = PropertyChanged; if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName)); } } } <Window x:Class="RDotNetWPFTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" Title="MainWindow" Height="350" Width="525"> <Grid> <Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="134,128,0,0" VerticalAlignment="Top" Width="75" Click="button_Click"/> <TextBlock x:Name="textBlock" HorizontalAlignment="Left" Margin="134,93,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Width="328" Text="{Binding RowContents}"/> <TextBlock x:Name="rowIndex" HorizontalAlignment="Left" Margin="259,131,0,0" TextWrapping="Wrap" VerticalAlignment="Top" Text="{Binding RowIndex}"/> </Grid> </Window>