Featured post

c# - Usage of Server Side Controls in MVC Frame work -

i using asp.net 4.0 , mvc 2.0 web application. project requiremrnt have use server side control in application not possibl in noraml case. ideally want use adrotator control , datalist control. i saw few samples , references in codepleax mvc controllib howwver found less useful. can tell how utilize theese controls in asp.net application along mvc. note: please provide functionalities related adrotator , datalist controls not equivalent functionalities thanks in advace. mvc pages not use normal .net solution makes use of normal .net components impossible. a normal .net page use event driven solution call different methods service side mvc use actions , view completly different way handle things. also, mvc not use viewstate normal .net controlls require. found article discussing mixing of normal .net , mvc.

multithreading - Windows App. Thread Aborting Issue -


i'm working on application has make specific decisions based on files placed folder being watched file watcher.

part of decision making process involves renaming files before moving them off folder processed.

since i'm working files of different sizes created object checks file in seperate thread verify "available" , when fires event.

when run rename code inside available event works.

public void renamefile_test() {     string psfilepath = @"c:\file1.xlsx";     tgt_file target = new fileobject(psfilepath);     target.fileavailable += new fileeventhandler(onfileavailable);     target.fileunavailable += new fileeventhandler(onfileunavailable); }  private void onfileavailable(object source, fileeventargs e) {     ((fileobject)source).renamefile(@"c:\file2.xlsx"); } 

the problem i'm running when extensions different source file , rename file making call conversion factory returns factory object based on type of conversion , converts file accordingly before doing rename. when run particular piece of code in unit test works, factory object returned, , conversion happens correctly.

but when run within process the...

        moexcelapp = new application(); 

part of converting .xls or .xlsx .csv , "thread being aborted" error.

any thoughts?

update:

there bit more information , bit of map of how application works currently.

  • client application running fsw
  • on file created event creates fileobject passing in path of file.
  • on construction file validated: if file exists true then,

    thread toavailablecheck = new thread(new threadstart(availablecheck)); toavailablecheck.start(); 
  • the availablecheck method repeatedly tries open streamreader file until reader either created or number of attempts times out. if reader opened, fires fileavailable event, if not fires fileunavailable event, passing in event.

  • the client application wired catch events inside oncreated event of fsw.

  • the onfileavailable method calls rename functionality contains excel interop call.
  • if file being renamed (not converted, extensions stay same) move change name old file name new, , if conversion runs conversion factory object returns correct type of conversion based on extensions of source file , destination file name.
  • if simple rename works w/o problem. if conversion (which xls csv object returned part of factory) first thing create new application object. application bombs.

when test factory , conversion/rename process outside of thread , in own unit test process works w/o problem.

update:

i tested excel interop inside thread doing this:

[testmethod()] public void excelinteroptest() {     thread toexcelinteropthreadtest = new thread(new threadstart(instantiate_app));     toexcelinteropthreadtest.start(); }  private void instantiate_app() {     application moexcelapp = new application();     moexcelapp.quit(); } 

and on line application instatntiated got 'a first chance exception of type 'system.threading.threadabortexception' error.

so added;

toexcelinteropthreadtest.setapartmentstate(apartmentstate.mta); 

after thread instantiation , before thread start call , still got same error. i'm getting notion i'm going have reconsider design.

somebody calling thread.abort(). clr, trying shut program down because of unhandled exception. reason might see threadabortexception instead of real exception because using com server (like excel) in thread isn't single threaded apartment. check docs thread.setapartmentstate(). threadpool threads ones filesystemwatcher uses raise events cannot sta.

also check output window debugger notifications , use debug + exceptions, thrown box make debugger stop on first exception.


Comments

Popular posts from this blog

c# - Usage of Server Side Controls in MVC Frame work -

cocoa - Nesting arrays into NSDictionary object (Objective-C) -

ios - Very simple iPhone App crashes on UILabel settext -