Quantcast
Channel: R.NET
Viewing all articles
Browse latest Browse all 1634

Commented Unassigned: C# App crashes while getting row from dataframe [150]

$
0
0
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 scrolling issue is a WPF issue and its a fairly standard cross-thread problem, the reason it is difficult to figure out is because it appears that R itself is trying to do something with the the Windows message queue, but since R is a mingw port, we don't get debug symbols in our Microsoft debugger. You can build R under Windows with MinGW from source and attach the debugger to the process, but that is an extremely challenging thing to do if you don't have a background in those tools. When you see a problem like this, you usually you just wrap the method in a "CurrentDispatcher.BeginInvoke()" call and that'll let GUI operations happen on the appropriate thread with the dispatcher enabled. In this case, since its an indexer access that is databound to the grid, its difficult to shove everything into the BeginInvoke() call without causing some issues. Here's an example: object IList.this[int index] { get { if (_indexDictionary.ContainsKey(index)) return _indexDictionary[index]; Dispatcher.CurrentDispatcher.BeginInvoke((Action) (() => { var rowdata = GetRowData(index); object generetedObject = new MyDataframeRow { Col1 = rowdata[0], Col2 = rowdata[1], Col3 = rowdata[2] }; if (!_indexDictionary.ContainsKey(index)) { _indexDictionary.Add(index, generetedObject); } RaiseListChanged(new ListChangedEventArgs(ListChangedType.ItemAdded, index, index)); })); return new object(); } set {} } Unfortunately, what the above code says to me is that you need to re-think your caching and databinding strategy. My suspicion is that the issue has something to do with the console device trying to write a message, but that's just a guess. R is a complex beast and treating it like a clean datasource is probably not the easiest path to had down. If it were me, I would favor marshaling large blocks of data between C# and R over executing lots of little access calls due the the complexity of interacting with R. For the 'AccessViolation' issue, I was unable to reproduce it, even with 40,000 items. I do believe that there is something internal happening with R as every time you see that. It is unlikely that it is due to a bug in the R.Net source and again, I think it may have something to do with the console device. Every time I've had that issue it has been the fault of my device causing a C# exception that propagates into R's unmanaged DLLs and I was able to fix the exception by correcting my code. Again, deciphering that issue is difficult, and in one case required using a combination of static source analysis of the R tree and the MinGW debugger.

Viewing all articles
Browse latest Browse all 1634

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>