vb.net - TPL null reference visual basic task -


i'm developing control software robot in visual basic , cannot life of me figure out why execution of procedure, works flawlessly outside of task framework, not work when try run concurrently rest of code. i'm trying use tpl let procedure run in background while allowing user use gui in parallel (currently, program freezes during execution of procedure, , isn't active again until it's over, , can take hours). problem here couldn't solve looking @ other questions is, nullreferenceexception happens inside task area, if don't try run concurrently rest of software, exception never, ever happens. code i'm using:

dim taskspme = task(of boolean).factory.startnew(function()                                                      return mainform.startspme((spmepanel.spmecoordinates), spmepanel.waitingtimes, spmepanel.wellvolumes, spmepanel.stirposition, spmepanel.stirringspeed, spmepanel.stirringradius, spmepanel.hoverz, spmepanel.gridscaling, spmepanel.incrementwithin)                                                  end function) try     taskspme.wait()     msgbox("task return value: " & taskspme.result.tostring) catch ex aggregateexception     each fault in ex.innerexceptions         if typeof (fault) invalidoperationexception             msgbox("invalid operation exception")         elseif typeof (fault) nullreferenceexception             msgbox("null reference exception. " & fault.message.tostring)         elseif typeof (fault) io.filenotfoundexception             msgbox("file not found exception")         end if     next end try 

startspme(), located in gui class called mainform, function runs fine , returns boolean value if it's not called sort of parallel/concurrent framework. i've tried using parallel.invoke() , old threadpool stuff, , throw same exception, happens nullreferenceexception fault message says "object reference not set instance of object". tried performing trivial tasks inside startnew() argument, msgbox example, , run fine. imports

imports system.threading imports system.threading.tasks imports system.threading.thread 

can tell me i'm forgetting here? there conditions task called startnew() constructor perform? like, can not located in class? originally, didn't want call wait() method on task, since want program go gui while robot performs experiments, since nothing happens robot unless startspme() function outside of parallel task code, have no idea what's going wrong here.


Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -