Hi,
Having a slight problem with how to pass parameters to functions between
threads.
I have a form with a progress bar and a description label on it. It has a
public function
IncrementProgre ssBar() that just calls performstep on the progress bar.
On my main form I create a thread which creates the progress bar form
Then using
MethodInvoker mi = new MethodInvoker(m _ProgressBar.In crementProgress Bar);
this.BeginInvok e(mi);
I can get this function called wherever is appropriate.
All is fine. But I want a function that takes a string as a parameter so I
can dynamically update the description.
Any idea how to do this? I've searched google and found nothing so far.
I've tried
MethodInvoker mi = new MethodInvoker(m _ProgressBar.Up dateDescription );
object[] args = {m_txtUpdateDes cription.Text};
this.BeginInvok e(m_ProgressBar .UpdateTitle, args);
but the first line doesn't compile.
Rollasoc 3 8046
Sorry cut and pasted the wrong bit of code. (which obviously doesn't work)
It shoul have been
I've tried
MethodInvoker mi = new MethodInvoker(m _ProgressBar.Up dateDescription );
object[] args = {m_txtUpdateDes cription.Text};
this.BeginInvok e(m_ProgressBar .UpdateDescript ion, args);
but the first line doesn't compile.
"rollasoc" <ho*****@hotmai l.com> wrote in message
news:ud******** ******@TK2MSFTN GP10.phx.gbl... Hi,
Having a slight problem with how to pass parameters to functions between threads.
I have a form with a progress bar and a description label on it. It has a public function IncrementProgre ssBar() that just calls performstep on the progress bar.
On my main form I create a thread which creates the progress bar form
Then using
MethodInvoker mi = new MethodInvoker(m _ProgressBar.In crementProgress Bar);
this.BeginInvok e(mi);
I can get this function called wherever is appropriate.
All is fine. But I want a function that takes a string as a parameter so
I can dynamically update the description.
Any idea how to do this? I've searched google and found nothing so far.
I've tried
MethodInvoker mi = new MethodInvoker(m _ProgressBar.Up dateDescription );
object[] args = {m_txtUpdateDes cription.Text};
this.BeginInvok e(m_ProgressBar .UpdateTitle, args);
but the first line doesn't compile. Rollasoc
I don't understand why you need to use MethodInvoke in order to call your
function (It seems you are trying a combination of threading and
reflection). You could use something like the next sample, where I am using
the member variable "someMessag e" as a way of passing the string to the new
thread. Perhaps you will have to add some synchronization to the
someMessage variable.
public class MyClass
{
private string someMessage;
public void DoSomething()
{
//....
this.someMessag e = "Some Message";
new Thread(new ThreadStart(thi s.MyThreadFunct ion())).Start() ;
}
public void MyThreadFunctio n()
{
DoSomething(thi s.someMessage);
}
}
You could also consider sending some notifications to update the
slider/message. Sorry cut and pasted the wrong bit of code. (which obviously doesn't work)
It shoul have been I've tried
MethodInvoke r mi = new MethodInvoker(m _ProgressBar.Up dateDescription );
object[] args = {m_txtUpdateDes cription.Text};
this.BeginInvok e(m_ProgressBar .UpdateDescript ion, args);
but the first line doesn't compile.
"rollasoc" <ho*****@hotmai l.com> wrote in message news:ud******* *******@TK2MSFT NGP10.phx.gbl.. . Hi,
Having a slight problem with how to pass parameters to functions between threads.
I have a form with a progress bar and a description label on it. It has
a public function IncrementProgre ssBar() that just calls performstep on the progress bar.
On my main form I create a thread which creates the progress bar form
Then using
MethodInvoker mi = new MethodInvoker(m _ProgressBar.In crementProgress Bar);
this.BeginInvok e(mi);
I can get this function called wherever is appropriate.
All is fine. But I want a function that takes a string as a parameter so I can dynamically update the description.
Any idea how to do this? I've searched google and found nothing so far.
I've tried
MethodInvoker mi = new MethodInvoker(m _ProgressBar.Up dateDescription );
object[] args = {m_txtUpdateDes cription.Text};
this.BeginInvok e(m_ProgressBar .UpdateTitle, args);
but the first line doesn't compile. Rollasoc
Adrian Vinca [MSFT], Developer Division
--------------------------------------------------------------------
This reply is provided "AS IS", without warranty (express or implied).
Note: For the benefit of the community-at-large, all responses to this
message are best directed to the newsgroup/thread from which they
originated.
Your right. There was no need really. I was going on what few articles I
could find. I have since found some very useful articles on the microsoft
site.
Completely sorted the whole thing with delegates and using BeginInvoke on
them.
Works great now.
Rollasoc
"Adrian Vinca [MSFT]" <ad**********@o nline.microsoft .com> wrote in message
news:Am******** ******@cpmsftng xa06.phx.gbl... I don't understand why you need to use MethodInvoke in order to call your function (It seems you are trying a combination of threading and reflection). You could use something like the next sample, where I am
using the member variable "someMessag e" as a way of passing the string to the
new thread. Perhaps you will have to add some synchronization to the someMessage variable.
public class MyClass { private string someMessage;
public void DoSomething() { //.... this.someMessag e = "Some Message"; new Thread(new ThreadStart(thi s.MyThreadFunct ion())).Start() ;
}
public void MyThreadFunctio n() { DoSomething(thi s.someMessage); } }
You could also consider sending some notifications to update the slider/message.
Sorry cut and pasted the wrong bit of code. (which obviously doesn't
work) It shoul have been I've tried
MethodInvoke r mi = new MethodInvoker(m _ProgressBar.Up dateDescription );
object[] args = {m_txtUpdateDes cription.Text};
this.BeginInvok e(m_ProgressBar .UpdateDescript ion, args);
but the first line doesn't compile.
"rollasoc" <ho*****@hotmai l.com> wrote in message news:ud******* *******@TK2MSFT NGP10.phx.gbl.. . Hi,
Having a slight problem with how to pass parameters to functions
between threads.
I have a form with a progress bar and a description label on it. It
has a public function IncrementProgre ssBar() that just calls performstep on the progress bar.
On my main form I create a thread which creates the progress bar form
Then using
MethodInvoker mi = new
MethodInvoker(m _ProgressBar.In crementProgress Bar); this.BeginInvok e(mi);
I can get this function called wherever is appropriate.
All is fine. But I want a function that takes a string as a parameter
soI can dynamically update the description.
Any idea how to do this? I've searched google and found nothing so
far. I've tried
MethodInvoker mi = new MethodInvoker(m _ProgressBar.Up dateDescription );
object[] args = {m_txtUpdateDes cription.Text};
this.BeginInvok e(m_ProgressBar .UpdateTitle, args);
but the first line doesn't compile. Rollasoc
Adrian Vinca [MSFT], Developer Division -------------------------------------------------------------------- This reply is provided "AS IS", without warranty (express or implied).
Note: For the benefit of the community-at-large, all responses to this message are best directed to the newsgroup/thread from which they originated. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: zlatko |
last post by:
There is a form in an Access Project (.adp, Access front end with SQL
Server) for entering data into a table for temporary storing. Then, by
clicking a botton, several action stored procedures (update, append) should
be activated in order to transfer data to other tables.
I tried to avoid any coding in VB, as I am not a professional, but I have
found a statement in an article, that, unlike select queries, form's Input
Property can't be...
|
by: Pavils Jurjans |
last post by:
Hallo,
I have been programming for restricted environments where Internet Explorer
is a standard, so I haven't stumbled upon this problem until now, when I
need to write a DOM-compatible code.
The question is about best practices for passing parameters to an event
function.
I have, say, the following HTML:
|
by: No Spam |
last post by:
Dear Access 2003 Users,
Is there any way to launch Terminal Server from Access and pass along
the user name that is in a text box? I believe mstsc.exe can be
passed an IP address (/v), but can you also pass along a username or
password that sits on a form? Thank you.
Kevin
|
by: Carlos |
last post by:
Hi all,
I am familiar with passing parameters to a thread function using C++,
but I needt to learn it using C#. Can someone shed some light on
how to do this? Code snippets will be great to show me.
Thanks in advance,
Carlos
|
by: Paul Allan |
last post by:
I am new to ASP.net (intermediate ASP developer). I am developing a ASP.net
web application and I am having some difficulty calling and passing
parameters to a function that is declared in my "codebehind" page.
Function declaration:
Sub MyFunction(ByVal sender As Object, ByVal e As System.EventArgs)
| |
by: Mike Dinnis |
last post by:
Hi,
I've been working through a number of turorials to try to learn more about
retrieving data from a SQL database. I think i've mastered techniques where
i create a sql string in the page and pass it to the Db and retrieveing data
from a stored procedure, but I can't get the hang of parameters.
I have a method where I can get the parameters passed to the sp but it
doesn't want to return any results. Here's a copy of my code:
|
by: ingoweiss |
last post by:
Hi,
I am having trouble passing parameters of a Javascript subclass
constructor through to it's superclass constructor.
I am trying all sorts of things, including the below, but nothing
worked so far.
Thanks for any help!
|
by: Nab |
last post by:
I have just tried to pass parameters to a procedure in VB 2005 and realised
that you only need to pass the input parameter. The output parameter's value
will be returned without the need to pass it as was the case in the previous
version of VB e.g. VB .Net 2003.
Here's the procedure in the web service:
Public Sub Convert2Dollar(ByVal euroAmount As Double, ByRef usDollarAmount
As Double)
Dim exchangeRate As Double
exchangeRate = 10 / 6
|
by: tbringley |
last post by:
I am a c++ newbie, so please excuse the ignorance of this question.
I am interested in a way of having a class call a general member
function of another class.
Specifically, I am trying to write an ordinary differential equation
class that would solve a general equation in the form:
dx/dt = f(x,t).
The ode class shouldn't know anything about f, except how to call it.
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |