|
OK, here's a version of Hello that isn't static, it uses the same RunThis method as my earlier post:
public class MyClass
{
private string greeting = "Hello" ;
private string who = "world" ;
private void
Hello
(
object Who
)
{
System.Console.WriteLine ( "{0}, {1}!" , greeting , Who ) ;
}
public void
SayHello
(
)
{
RunThis ( new System.Threading.ParameterizedThreadStart ( Hello ) , who ) ;
}
}
Again, the RunThis method doesn't add much to the design, but it should do what you need.
|
|
|
|
|
thnx,
but it is a little problem..
in your example there is a method named "hello".
in my classlibary that i will create DLL later from him, the method "hello" not existent.
i will try to explain.
i want to create dll. that open new thread of unknown method, or in other words, start new thread by dynamic method.
the dll that i will create i will add him to the reference on new windows application.
than,between all methods i will choose in the form to create a new thread, from the dll that i created.
but!, i can't compiled the classlibary, because, the method isnt existent there. he existent in the windows application. the class dont know the method.
in your example the method is "hello" and there in no problem to call for new thread because the threadstart see a method name (hello) and not variable(dynamic method mention as string)
i hope you understand me. thnx for the help =]
|
|
|
|
|
sorryy..it's works!!!
thnx my friend for your help!
|
|
|
|
|
|
When we change a project type from a DLL to EXE or vice versa, what exactly internally happens? How CLR know that this is executable? Is there any tag in the MSIL generated for that assembly? How to check it? What I tried, I have a DLL without Main. I compiled it and used it. Then I put Main in it and recompiled. Then I renamed Test.Dll to Test.Exe but I got this
E:\AssemblyVersioning\DotNetFunda\bin\Debug\Test.exe is not a valid Win32 application.
I want to know the internals of EXE and DLL.
Jayant D. Kulkarni
|
|
|
|
|
|
An EXE is a specially packaged file that contains information on how to start running the code in the file in a Windows process. A DLL only contains code, not all the housekeeping information. A program called a linker is used to link OS related housekeeping code into the EXE file to make it executable.
Semicolons. the number one seller of ostomy bags world wide. - dan neely
|
|
|
|
|
using System;<br />
using System.Collections.Generic;<br />
using System.ComponentModel;<br />
using System.Configuration.Install;<br />
using Microsoft.Win32;<br />
using System.Reflection;<br />
using System.IO;<br />
using System.Diagnostics;<br />
using System.Windows.Forms;<br />
<br />
namespace WindowsControlLibrary1<br />
{<br />
[RunInstaller(true)]<br />
public partial class CustomInstaller : Installer<br />
{<br />
public CustomInstaller()<br />
{<br />
InitializeComponent();<br />
}<br />
<br />
protected override void OnAfterInstall(System.Collections.IDictionary savedState)<br />
{<br />
string programName = "\"" + CeAppMgrExe + "\"";<br />
string programArg = "\"" + IniFilePath + "\"";<br />
<br />
MessageBox.Show(programName + " " + programArg);<br />
Process.Start(programName, programArg);<br />
base.OnAfterInstall(savedState);<br />
}<br />
<br />
const string _ceAppMgRegistryPath = @"software\Microsoft\Windows\CurrentVersion\App Paths\CEAppMgr.exe";<br />
const string _iniFileName = "PDARAM.ini";<br />
const string _filePrefix = @"file:\";<br />
string CeAppMgrExe<br />
{<br />
get<br />
{<br />
RegistryKey subKey = null;<br />
string exePath = null;<br />
try<br />
{<br />
subKey = Registry.LocalMachine.OpenSubKey(_ceAppMgRegistryPath);<br />
exePath = (string) subKey.GetValue("");<br />
}<br />
finally<br />
{<br />
if (subKey != null)<br />
subKey.Close();<br />
}<br />
return exePath;<br />
<br />
}<br />
}<br />
string IniFilePath<br />
{<br />
get<br />
{<br />
<br />
string installFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);<br />
string iniFilePath = Path.Combine(installFolder, _iniFileName);<br />
if (iniFilePath.StartsWith(_filePrefix))<br />
{<br />
<br />
int index = _filePrefix.Length;<br />
iniFilePath = iniFilePath.Substring(index);<br />
<br />
}<br />
return iniFilePath;<br />
<br />
}<br />
}<br />
}<br />
}<br />
Can anyonehelp me? I am buliding the Desktop installer, and it starts the install proccess, but tells me there is an error in my setup file?
<b>This is my INI file</b>
[CEAppManager]<br />
Version = 1.0<br />
Componet = DeviceApplication1<br />
<br />
[DeviceApplication1]<br />
Description = PDA RAM Data Collection Application<br />
CabFiles = SmartDeviceCab1.CAB<br />
Computer Programmer Web/Mobile .NET
|
|
|
|
|
Situation:
There is a page where left side has a menu which is static and right side has screens according to the menu selected. If I change something on the page and without saving the content I click on the other menu.
Requirment:
A popup should popup- "Do you want to save the content of the page", before it redirects to the page of the menu selected.
Conditions:
If I have saved the changes then,if I click on some other menu, the message should not popup.
If I save the changes made then again I change something on that page, then, the message should popup.
|
|
|
|
|
Does 'redirect' mean this is an ASP.NET question?
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I think you need to be more specific to get an answer to this question. What is it that you want help with?
|
|
|
|
|
Hello everyone,
When we invoke Set/Reset/WaitOne method on an object instance of ManualResetEvent, do we need to make it thread safe? i.e. make sure only one thread is invoking Set/Reset/WaitOne by some synchronization approach, like lock or Monitor?
thanks in advance,
George
|
|
|
|
|
When WaitOne() is called by multiple threads, it will be placed in a queue. When ManualResetEvent 's Set() is called it will signal all the threads waiting in the queue. If you want to signal only one thread in the WaitOne() queue, you need to use AutoresetEvent instead.
|
|
|
|
|
Thanks N a v a n e e t h,
I think I have not made myself understood in my original question. My question is, when we invoke methods in ManualResetEvent, like Set/Reset/WaitOne, whether we need to synchronize the function call?
Here is some code to show my question, whether we need to write code like this?
lock (_SomeManualResetEventInstanceLock)
{
_SomeManualResetEventInstance.Set();
}
lock (_SomeManualResetEventInstanceLock)
{
_SomeManualResetEventInstance.Reset();
}
lock (_SomeManualResetEventInstanceLock)
{
_SomeManualResetEventInstance.WaitOne();
}
regards,
George
|
|
|
|
|
Read this[^]. The part about Thread Safety should help you.
Scott P
“It is practically impossible to teach good programming to students that have had a prior exposure to BASIC: as potential programmers they are mentally mutilated beyond hope of regeneration.”
-Edsger Dijkstra
|
|
|
|
|
Thanks Scott,
After reading and learning, I think all the methods of ManualResetEvent is thread safe and no need to add lock, right?
regards,
George
|
|
|
|
|
George_George wrote: After reading and learning, I think all the methods of ManualResetEvent is thread safe and no need to add lock, right?
George if you can't understand this:
Thread Safety
This type is safe for multithreaded operations.
Then there is no hope for you.
led mike
|
|
|
|
|
Thanks led mike,
I appreciate your help.
regards,
George
|
|
|
|
|
An abstract class is a special kind of class that cannot be instantiated.No funciton definition can be done in these type of classes.
So what's the advantaghe to incorporate these kind of classes in our project?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
As a base class.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
This is further to ur reply.
If i say , what's the need of such a base class , which doesnot have funciton definition , only contains funciton declaration.
I can also create such class , where i am defining the funcitons , further , i can override the base class functions , if needed.
Sir , Isn't that ?
If you have an apple & I have an apple and we exchange our apples, then each of us will still have only one apple but if you have an idea & I have an idea and we exchange our ideas, then each of us will have two ideas!
|
|
|
|
|
For example, I wrote a paint program. All my paint tools derived from a Tool class. Tool is not useful, it merely defines the base. So, I don't want to be able to create Tool, only it's derived classes.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Pankaj Garg wrote: No funciton definition can be done in these type of classes.
What do you mean? It's quite possible to have methods and properties in the abstract class. The only limitation is that it cannot be instantiated. As previously stated you use them as base classes that can contain common functionality that all derived classes need/can make use of.
|
|
|
|
|
In addition to the answers already given, read up on Polymorphism[^] as it relates to OOP.
|
|
|
|
|
The abstract keyword is for classes which forms the base for other classes, but does not implement full functionality by itself. You can look at it as a safety net of sorts.
--
Kein Mitleid Für Die Mehrheit
|
|
|
|