VS 2008 Passing A Class Method In A New Thread

May 14, 2010

I am looking for a way to pass a class method into a new thread. On my form I have a few object that contain methods.

For example obj1.doWork.

Now I want to do

Example
Dim t as new Thread
t = new Thread(AddressOf obj1.doWork)
t.start()

However I get an error on this saying:

Error1Overload resolution failed because no accessible 'New' is most specific for these arguments:
'Public Sub New(start As System.Threading.ParameterizedThreadStart)': Not most specific.
'Public Sub New(start As System.Threading.ThreadStart)': Not most specific.

View 11 Replies


ADVERTISEMENT

Call A Method That Started On A Background Thread On The UI Thread Calling BeginInvoke And Passing In A Delegate?

Aug 27, 2011

I am trying to call a method that started on a background thread on the UI thread calling BeginInvoke and passing in a delegate as follows:

Dispatcher.BeginInvoke(Function() UpdateApplicationDataUI())

to call this method:

Private Sub UpdateApplicationDataUI()
...
End Sub

However, I get an error in the call to BeginInvoke (the UpdateApplicationDataUI portion of the delegate is stating "Expression does not produce a value").

Me.Dispatcher.BeginInvoke(Function() New Action(AddressOf UpdateApplicationDataUI))

View 1 Replies

Call Method Base Class In Program Passing Sub Class Objects?

Apr 22, 2012

Base class has one field to hold numeric balance value. With 2 methods that accept arguments for adding and subtracting the new input calculating new balance. Sub class has four fields dates, transaction, memo and amount.I have a deposit form, and withdraw form. Each time one transaction is entered it creates an object with sub class fields, then adds to the account collection. My problem is not understanding how to call the deposit/withdraw method and pass the current transaction amount back to the base class to alculate the new balance. Does anyone have any links to information/tutorials on how to perform something like this? As you can see with my code I have tried various different approaches without any success.

[Code]...

View 5 Replies

VS 2010 Multithreading, Putting Class Method On New Thread?

Jun 4, 2011

Right now I have a Email class that has all the properties of an email to send it, and then a SendEmail function which takes those properties and uses them in the following

Public Function SendEmail()
'Exception handling
Try

[Code]....

The loop goes through each email in the array to process its email, however with the multithreaded function I cannot call

"EmailArray(i).ThreadSendBatchEmail()"

So how do I call an objects method when its on a different thread?

And I'm making it multithreaded so I can easily pause the process, and because the program freezes when the send() function is working, this would resolve that.

View 17 Replies

VS 2008 Passing A Queue To A Thread?

Jan 14, 2011

I've passed object sucessfully to threads in the past but I'm stumped on this one:-

HTML

Public Class TileDownload
Structure RequiredTileDetails
Public MapID As String

[Code].....

View 2 Replies

Strongly-typed Generic Method Invokes Its Argument's Base Class Method Instead Of A Shadowed Method In T?

Oct 19, 2010

Consider a MyForm class that contains a shadowed implementation of Show(). It also contains a CreateForm() method, which accepts an instance of the form and calls the shadowed sub:

[Code]....

View 3 Replies

VS 2008 - Passing A Object Data To A Class?

Oct 5, 2010

I've got a main form (Form1.vb) where I created some controls (with the Designer).I've created a class myTextBox, inheriting from TextBox, in myTextBox.vb.In the main form, I call procedures from myTextBox. The issue is, those procedures use values from the Form controls. So the class doesn't recognise them as initialised.What's the best solution for this?I think I could pass the object itself as a parameter but doing it on each call seems a bitredundant and it thickens the code.Is there any way to access the Form1 controls and objects directly from the myTextBox.vb class?

View 6 Replies

VS 2008 - Passing Class As Argument For Function

Mar 23, 2010

VB.NET is not letting me dance with both feet, or piss with both hands. I've got one foot and one arm tied behind my back at every turn. I want to use this statement in a function:
Return CType(Formatter.Deserialize(FS), DS)
Seems doable, right?

Function ReadFileStream(ByRef FS As FileStream, ByRef DS As Object)
Dim Formatter As New BinaryFormatter
FS.Position = 0
Return CType(Formatter.Deserialize(FS), DS)
End Function

Right? I mean, CType only accepts a class name as the second argument. I can't give it an instance of a class, or it croaks. Yet if I try to pass the class name as the argument to that function:
DataInfo = ReadFileStream(FileStream1, DataStruct)

VB.NET croaks on this, too, complaining that "'DataStruct' is a type and cannot be used as an expression.". It's used as an expression by CType just fine outside of the function. Does the VB.NET legislature provide a clause that allows for a 'Type' to be passed as an argument in a function? Writing all the supporting code ten million times to deserialize a file using CType ten million times in a large application will get very complicated and tricky very quickly. It should be handled by a routine so that any cases and adjustments that come up can be dealt with in one spot.

View 8 Replies

Run A Method On The Main Thread From A Separate Thread?

Dec 31, 2010

I'm reading data from a serial port, but the DataReceived event of SerialPort is handled on it's own thread. I want to handle this on the main thread, but simply declaring an event and raising it still results in it being processed on the SerialPort thread. I'm assuming I need to declare a delegate I can call, but I don't see how that would work.

For example, I want to call Sub HandleDataReceived() on the main thread from the DataReceived thread, having HandleDataReceived() run on the main thread. How would I do this?

View 1 Replies

BackgroundWorker Thread Communicate With The Primary UI Thread When Encapsulated In A Class?

Jul 1, 2010

A BackgroundWorker thread can pass data to the primary thread. It does it via the RunWorkerCompleted and ProgressChanged events, which I believe run in the primary thread. I would like to encapsulate the BackgroundWorker control in a class so that I can instantiate it more than once. But I don't know how the BGW can then communicate with the primary thread. If the BGW control is within a class, it does not have access to the properties outside the class. In that case, how can the BGW pass data to the thread that instantiated it?

[Code]....

View 3 Replies

VS 2008 Enum And Radio Boxes-passing Info To Business Class?

Jan 29, 2011

I'm trying to pass data from the main form to a business class form for calculation.I have 3 types of cars and I can't get the code right to pass that to the business form. It seems correct to me, but obviously, it's not.This is the code for the calculate button, I can't figure out why its telling me that CarSize is not a member of the business form when I have it in the Enum statement at the top. I'm going by what the book says and this appears right according to it.

Dim CarTypeInteger As Integer
'determine the car size from radio buttons
If LuxuryRadioButton.Checked Then

[code]....

In the book it says to specify the class name when declaring the enum on the business form. So to me it looks like it should be -RentalRate.CarSize.Luxury The error I have is 'CarSize' is not a member of the 'ChristiansCarRentals.RentalRate'.

View 6 Replies

Abort Menthod Of Thread Class Is Not Aborting The Thread?

Apr 1, 2010

I am using vb.net 2005In my form load procedure I am starting a background thread.The thread is declared as public.

Public
threadMonitorWMI As System.Threading.Thread
And started in form_load

[code].....

View 2 Replies

VS 2008 - Using PrintToFile Method From PrintForm Class?

Dec 16, 2009

I'm trying to use PrintToFile from the Power Packs PrintForm Class and I have a question. I'm able to save the form to a file, but now how to print it later if needed. MSDN says that it's saved as an Encapsulated PostScript file. Adobe Illustrator claims it will open EPS file, but it won't open this one. How I can print this file in vb.net? If you've never used this before, here is my sample code to save the form to file in case someone wants to test it out.

If SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.PrintForm1.PrintFileName = SaveFileDialog1.FileName & ".eps"Me.PrintForm1.PrintAction = Printing.PrintAction.PrintToFile
Me.PrintForm1.Print(Me,PowerPacks.Printing.PrintForm.PrintOption.Scrollable)
End If

View 3 Replies

VS 2008 Getting Information From Calling Method's Class

Apr 11, 2009

I'm working on a base class right now, here's a basic rundown of it:[code]The problem is, in the Public Class bar example, some classes may implement MyInterface, and others don't. What I'd like to be able to do is have the sub New() in the structure in the base class "Foo" be able to tell if the class calling it (either the Base class, or the child class) implements MyInterface or not.

View 8 Replies

VS 2008 Make The "MouseProc" Method Be On A Separate Thread?

Mar 27, 2010

I'm working with Windows 7 and my application is having some troubles with the SetWindowsHookEx API - everything works fine but when my application is not responsive (gets into a loop) the hook automatically stops (LowLevelHookTimeOut) thats because my application haven't processed the hook messages in time (In this case, mouse movements).When I install the hook a method called "MouseProc" gets the hook messages (mouse movements and clicks) the problem is that this method ("MouseProc") is on the same thread of my app UI - is there is any way to make the "MouseProc" method be on a separate thread? I have attached the class.When the user declares this class as new the hook is automaticlly installed, here is an example:

Dim WithEvents MHook As MouseHook
Private Sub Form_Load(Some Args)
MHook = New MouseHook()
'Mouse hook installed

[code].....

But it's not really working.

View 6 Replies

VS 2008 Cross-thread Error, Change Control Property By (other) Class Event PropertyChanged?

Apr 1, 2010

I need some help to understand my options to get this working. I try to update a textbox control by a property-changed event from a class variable. I've digged around for a day and have a vague understanding that this can be solved in three ways:

1. Using some "if InvokeRequired", "Invoke" code in the handler method
2. By programming a special delegate class for this variable
3. By using a databinding directly linking the control (textbox) to the class event

Now.. Are these options correct? And would it be possible to get some help to show these three solutions in actual code (relevant to mine)? I can't seem to manage to sort all the information to a working code. Also, what are the pros and cons of the different solutions?

As my code stands now, it's obviously none of the above, as it gives a cross-thread error, as indicated.

[Code]...

View 2 Replies

Passing A Structure From One Class To Another Class In A Applications (VS2008)

Apr 7, 2010

I'm sure there are several ways of achieving my goal but I am after opinions on what you think is the best option. I'm writing a vb.net application which (amongst other thinks) interfaces with media players in the home. Because there are different types of media playersI'm trying to structure it so each type of media player has it's own class which interfaces to a management class which sits on top of all the different devices types.

The device classes are responsible for discovering the phsyical devices and returning that information up to the management class. A device class may be responsible for monitoring 1 or more physical devices so..

[Code]...

View 1 Replies

Yes Another 'Passing Variables Thread"

Jan 7, 2012

VBasic / VS2008 / .NET 3.5 / Meas Studio 8.5 I've searched and seen a number of convoluted ways of doing this but.... What I am trying to do should be simple and in my mind (and from previous experience) it should work. It doesn't At least not after 10 hours of tweaking, editing, researching....

Straightforward project, 3 components - MainModule, MainForm, CNCNoForm. I declare public var NCPgmNo in the module. I open the CNCNoForm from the MainForm. This form has 2 controls - Numeric Up/Down Box & Close Button. I enter a number in the Num box (read only property is set to false), then assign the value to the var. NCPgmNo in the value-changed event sub. I close the form, returning to the MainForm. The variable does not pass even though it is public and declared in the module. I tried removing it from the Numupdown event and assigned the var before 'me.close'. Still N/G.

If I put a breakpoint right after the line that assigns the var, it is correct. It just does not pass to the MainForm. I started with a textbox, then changed to a Meas. Studio Numeric control, finally Numeric up/down. Same results with all 3. I though the CNCNoForm was broken so I removed it from the project and rebuilt it with a new name (yes name references in the MainForm and MainModule are correct). One other thing. If I call the CNCNoForm repeatedly, it reads the previous value. I am ready to give up computers and take up farming or hiking.

[Code]....

View 7 Replies

Get The Name Of Parent Method/class/file Name Inside Other Method Call?

Feb 16, 2010

I will try to explain what I need.Let's say that I have a class like this:

Public Class Example1 Public Sub ToBeCalled()

[Code]...

View 5 Replies

Passing Data From One Running Thread To Another Running Thread?

Jan 14, 2011

I have on timer thread that needs to pass every time a different data to another running thread to make the calculations.

View 5 Replies

Passing Data From A Form Back To A Thread

Sep 20, 2010

In a threadpooling situation is it possible for a modal form to be opened and data from that form to be passed back to the thread that opened it ?

View 1 Replies

Threading.thread Addressof Passing Variables

Apr 16, 2012

I am trying to pass some status from a IP call in a shared sub to a label on my form. This is the current code that i am using:

[Code]....

View 1 Replies

Passing List / Collection From Class To Class

Apr 28, 2009

I seem to have problem with passing a collection/sorted list/ list of strings from one class to another.I am using property procedure to pass it, however nothing is sent to another class. There isn't any error messages either.[code]

View 3 Replies

Passing A Setting To A Method?

Jan 5, 2011

I have a method which must take an application setting as a parameter. E.g. MyMethod(ByVal setting As Setting)This example doesn't work because I do not know what to declare the variable as. Can someone please advise me on how I can get the method toaccept a My.Settings settings? My intentions are strictly to make the program

View 4 Replies

Passing DataSet To A Method Using CodeDOM?

Jun 17, 2010

In my main application i am trying to run Pre-defined Code blocks that the user has created. I would also like to send a DataSet as a parameter when the code is compiled. Is this possible. Currently I can pass in single values by assigning them as a string in the code wrapper through the <%= input %> expression. Then i compile this as source.

[Code]...

View 1 Replies

Passing Variables From One Method To Another For Log File?

May 15, 2012

I deleting the files of certain age in a directory and also need to write a log file. So my question is how can we pass a variable from one method to another?
Example : Dotnet.Explorer

View 3 Replies

Create A New Class That Inherits From The Base Form Class And Define A New() Method With Parameters?

Oct 1, 2008

I've been creating short test apps repeatedly to try to understand some of the concepts in VB.NET.For the most part it has been illuminating.I read Bucky's .NET knowlegebase tutorial on passing objects as parameters to newly created forms. He shows how to create a new class that inherits from the base form class and define a New() method with parameters Extending the concept I thought about doing the same thing with a form that was created at design-time (In this case Form2).

[Code]...

View 6 Replies

Dynamically Call A Function With Delegates By Passing A String To A Background Thread?

May 20, 2009

How do I dynamically call a function with delegates by passing a string to a background thread in VB.NET?

Currently my code is this

Public Sub invertImageBK(ByVal image As Bitmap)
Dim snxl As System.ComponentModel.BackgroundWorker = createBW()
snxl.RunWorkerAsync(New ImageProperties(image.Clone, "invertImage", Nothing))

[Code].....

View 1 Replies

.net - Suppress A Property Or Method From A Base-class In A Derived Class?

Apr 7, 2011

Supose a base class

Public Class airplane
Private var_num_seats As Integer
Private var_num_engines As Integer

[code]....

Obviously, I don't wish that the class Glider has the method "start_engines" neither the property "num_engines". Otherwise, other child classes may have. How can I supress these property and method in child class, not just ignoring (if I can)?

View 2 Replies

Converting String To Class And Dynamically Raising A Known Method Of That Class?

Oct 5, 2010

class

eg: dim classobj = xyz("CLASS_NAME") ' where classname is a valid class name
and dynamically raising a known method of that class on that newly created object or class reference.

[code].....

View 4 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved