Click here to Skip to main content
15,885,546 members
Home / Discussions / C#
   

C#

 
AnswerRe: Issue with accessing object in background thread when converter value updates Pin
Gerry Schmitz14-Jul-16 5:32
mveGerry Schmitz14-Jul-16 5:32 
GeneralRe: Issue with accessing object in background thread when converter value updates Pin
Imagiv14-Jul-16 6:26
Imagiv14-Jul-16 6:26 
GeneralRe: Issue with accessing object in background thread when converter value updates Pin
Gerry Schmitz14-Jul-16 7:06
mveGerry Schmitz14-Jul-16 7:06 
Questionc# network programming(Server /Client ) Pin
Mostafa_Hosseini13-Jul-16 6:44
Mostafa_Hosseini13-Jul-16 6:44 
AnswerRe: c# network programming(Server /Client ) Pin
Super Lloyd13-Jul-16 13:17
Super Lloyd13-Jul-16 13:17 
Question[SOLVED] System.AccessViolationException When Calling Dll Function Again Pin
Django_Untaken13-Jul-16 5:39
Django_Untaken13-Jul-16 5:39 
AnswerRe: System.AccessViolationException When Calling Dll Function Again Pin
Dave Kreskowiak13-Jul-16 5:55
mveDave Kreskowiak13-Jul-16 5:55 
AnswerRe: System.AccessViolationException When Calling Dll Function Again Pin
Luc Pattyn13-Jul-16 8:33
sitebuilderLuc Pattyn13-Jul-16 8:33 
Hi,

I'm assuming you are using WinForms and those textXXXFile objects are Controls, maybe TextBoxes. A Control should only be created and used by a single thread, most often that would be the main or "GUI thread"; violating this rule is bound to give you AccessViolation trouble.

I would recommend you use one (or more if you think you must) BackgroundWorker objects ibstead of bare Threads. A BGW will execute most of its task on a separate thread (which it borrows from the ThreadPool), however it also offers progress and completion events which execute on the main thread (assuming you created the BGW on the main thread) so all AccessViolations would disappear.

If you're unfamiliar with the BGW class, read up on it, I'm pretty sure CP has some fine articles about it.

Note 1: you should get the inputfile before entering the DoWork event.

Note 2: you could reuse the BGW object, or create a new one, that is up to you.

Note 3: there are some BGW properties you have to set true explicitly for it to activate all its goodies!


good luck

Smile | :)
Luc Pattyn [My Articles] Nil Volentibus Arduum

GeneralRe: System.AccessViolationException When Calling Dll Function Again Pin
Bernhard Hiller14-Jul-16 3:59
Bernhard Hiller14-Jul-16 3:59 
AnswerRe: System.AccessViolationException When Calling Dll Function Again Pin
Slacker00713-Jul-16 8:35
professionalSlacker00713-Jul-16 8:35 
AnswerRe: System.AccessViolationException When Calling Dll Function Again Pin
Bernhard Hiller13-Jul-16 21:42
Bernhard Hiller13-Jul-16 21:42 
AnswerRe: [SOLVED] System.AccessViolationException When Calling Dll Function Again Pin
Member 132605384-Nov-19 16:38
Member 132605384-Nov-19 16:38 
GeneralRe: [SOLVED] System.AccessViolationException When Calling Dll Function Again Pin
Django_Untaken11-Nov-19 20:49
Django_Untaken11-Nov-19 20:49 
AnswerRe: [SOLVED] System.AccessViolationException When Calling Dll Function Again Pin
Member 162142615-Apr-20 0:28
Member 162142615-Apr-20 0:28 
Questionthe action cannot be completed because the file is open in w3wp.exe Pin
Rocky Nandu12-Jul-16 21:05
Rocky Nandu12-Jul-16 21:05 
AnswerRe: the action cannot be completed because the file is open in w3wp.exe Pin
OriginalGriff12-Jul-16 21:30
mveOriginalGriff12-Jul-16 21:30 
AnswerRe: the action cannot be completed because the file is open in w3wp.exe Pin
Pete O'Hanlon12-Jul-16 22:49
mvePete O'Hanlon12-Jul-16 22:49 
AnswerRe: the action cannot be completed because the file is open in w3wp.exe Pin
F-ES Sitecore12-Jul-16 23:40
professionalF-ES Sitecore12-Jul-16 23:40 
GeneralRe: the action cannot be completed because the file is open in w3wp.exe Pin
Rocky Nandu29-Jul-16 1:48
Rocky Nandu29-Jul-16 1:48 
QuestionHow To Wire Up This Event Pin
Kevin Marois12-Jul-16 14:42
professionalKevin Marois12-Jul-16 14:42 
AnswerRe: How To Wire Up This Event Pin
Super Lloyd12-Jul-16 16:43
Super Lloyd12-Jul-16 16:43 
GeneralRe: How To Wire Up This Event Pin
Kevin Marois13-Jul-16 6:14
professionalKevin Marois13-Jul-16 6:14 
GeneralRe: How To Wire Up This Event Pin
Super Lloyd13-Jul-16 7:07
Super Lloyd13-Jul-16 7:07 
GeneralRe: How To Wire Up This Event Pin
Kevin Marois13-Jul-16 7:10
professionalKevin Marois13-Jul-16 7:10 
GeneralRe: How To Wire Up This Event Pin
Super Lloyd13-Jul-16 13:12
Super Lloyd13-Jul-16 13:12 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.