c# - SpreadSheetGear IWorksheet cells reading from multiple cells throwing exception -


i trying read cells spreadsheetgear iworkbook it's getting exception . expected ?

    (int = wr; j <= er; i++) {     (int j = sc; j <= ec; j++)                       {                            var rng = worksheet.range[i, j];                           var celldata = getcell(rng, worksheet);                           row.c.add(celldata.index, celldata);                       }                       }                        void getcell (spreadsheetgear.irange rng,spreadsheetgear.iworksheet worksheet) {                       // cpu bound task                         if (rng.locked)                     {                         var locked = 1;                     }                       }   ===================  parllelism code parallel.for (sr ,er+1 ,i => { (int j = sc; j <= ec; j++)                   {                        var rng = worksheet.range[i, j];                       var celldata = getcell(rng, worksheet);                       row.c.add(celldata.index, celldata);                   }                   }                    void getcell (spreadsheetgear.irange rng,spreadsheetgear.iworksheet worksheet) {                   // cpu bound task                     if (rng.locked)                 {                     var locked = 1;                 }                   } 

i trying parallelise cpu bound task throwing exception when tried use parallelism below block throwing exception

 if (rng.locked)                     {                         var locked = 1;                     }                       } 

exceptions sort of scenario expected, cannot parallelize kind of work on workbook. in case of parallel code, multiple threads accessing workbook simultaneously, not supported , leads unexpected / bad internal state , exception seeing.

spreadsheetgear support accessing workbooks multiple threads, comes big caveat: each thread must work between calls iworkbookset.getlock() / releaselock(), guarantee 1 thread access workbook @ given time. task of parallelizing work, api no since using getlock() / releaselock() turn parallel task serial one. bottom-line, there no way safely parallelize sort of task spreadsheetgear.


Comments

Popular posts from this blog

ubuntu - PHP script to find files of certain extensions in a directory, returns populated array when run in browser, but empty array when run from terminal -

php - How can i create a user dashboard -

javascript - How to detect toggling of the fullscreen-toolbar in jQuery Mobile? -