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.

c# - BackgroundWorker and instance variables -


one thing that's confused me how backgroundworker seems have thread-safe access instance variables of surrounding class.

given basic class:

public class backgroundprocessor {     public list<int> items { get; private set; }      public backgroundprocessor(ienumerable<int> items)     {         items = new list<int>(items);     }      public void dowork()     {         backgroundworker worker = new backgroundworker();         worker.runworkercompleted += new runworkercompletedeventhandler(worker_runworkercompleted);         worker.dowork += new doworkeventhandler(worker_dowork);         worker.runworkerasync();     }      void worker_dowork(object sender, doworkeventargs e)     {         var processor = new processingclass();          processor.process(this.items); //accessing instance variable     }      void worker_runworkercompleted(object sender, runworkercompletedeventargs e)     {         //stuff goes here     } } 

am erroneous in assumption the call processor.process(this.points); thread-safe call? how don't cross-thread access violation?

i'm sure it's obvious, has confused me.

it's not thread-safe, looks way. cross-thread exception gui controls. there hard requirement gui controls accessed thread created them. framework takes time check calls other threads. note orthogonal synchronization issues (at least our point of view, not point of view of user subsystem) still use locks prevent multiple threads accessing control @ same time , still cross-thread violation.

since member variable not gui control, there no check cross-thread calls, nor there check race conditions. have locking or other mechanism. no exception unless collection classes corrupted. don't believe thread-safe, i'm not sure ends meaning, nor have ever shared kinds of variables between threads running @ same time, haven't had problem. suffice say, it's better right thing hope collection classes magically work.


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 -