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: the dispatcher thread is running and then fire off a property changed event so the databinding engine can refresh based off the new item. I don't think any of that precludes you from implementing a paging scheme in the background so that your requests from R are larger than just a single item. FWIW, here's some untested example code for fetching per item in the vein of what was suggested for the OP of this issue, but adjusted for your restrictions. public class MyData : BindingList<Customer> { private readonly REngine _rServer; public MyData(REngine rserver) { if (rserver == null) throw new ArgumentNullException("rserver"); _rServer = rserver; } public new Customer this[int index] { get { if (index >= Count) { Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => { var command = string.Format("rowd <- Dataset1[{0},]", index + 1); _rServer.Evaluate(command); var sexp = _rServer.GetSymbol("rowd"); var rowdata = sexp.AsCharacter().ToArray(); var customer = new Customer(rowdata[0], rowdata[1]); SetItem(index, customer); })); return new Customer("temp", "temp"); } return base[index]; } set {} } }
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: the dispatcher thread is running and then fire off a property changed event so the databinding engine can refresh based off the new item. I don't think any of that precludes you from implementing a paging scheme in the background so that your requests from R are larger than just a single item. FWIW, here's some untested example code for fetching per item in the vein of what was suggested for the OP of this issue, but adjusted for your restrictions. public class MyData : BindingList<Customer> { private readonly REngine _rServer; public MyData(REngine rserver) { if (rserver == null) throw new ArgumentNullException("rserver"); _rServer = rserver; } public new Customer this[int index] { get { if (index >= Count) { Dispatcher.CurrentDispatcher.BeginInvoke((Action)(() => { var command = string.Format("rowd <- Dataset1[{0},]", index + 1); _rServer.Evaluate(command); var sexp = _rServer.GetSymbol("rowd"); var rowdata = sexp.AsCharacter().ToArray(); var customer = new Customer(rowdata[0], rowdata[1]); SetItem(index, customer); })); return new Customer("temp", "temp"); } return base[index]; } set {} } }