|
More commonly refered to as bitwise operation, you use the | and & operators. (& to interpret if a particular "bit" is set, and | to set a particular "bit").
Some examples.
<br />
int myNum = 1;<br />
myNum = myNum | 2;
To use this in a boolean expression, you can check the result != 0 (which effectively means the "bit is set".
<br />
if( (myNum & 2) != 0)<br />
{<br />
}
|
|
|
|
|
Yeah, what he said. Plus, look at the FlagsAttribute for enumerations.
|
|
|
|
|
Hi all,
I have a child form compiled as DLL (project1) to be used from another Main Application (project2). Now this window has many settings.
The Main Application can create multiple instances from the child form (project1).
All these instances will share the same settings.
My question is how can I make each instance create its own settings?
Thank you
|
|
|
|
|
I assume you're asking for persistent settings. Have you looked at any of the classes in System.Configuration namespace? You should be able to create a new app settings group per instance.
|
|
|
|
|
Hi All,
I need to run 3 methods parallaly.Then I have used Threading for that. Here is the code.
public void threadtest()
{
Thread SpecialThread = new Thread(new ThreadStart(this.GetSpecial));
Thread BulkThread = new Thread(new ThreadStart(this.GetBulk));
Thread NormalThread = new Thread(new ThreadStart(this.GetNormal));
SpecialThread.Start();
BulkThread.Start();
NormalThread.Start();
SpecialThread.Join();
BulkThread.Join();
NormalThread.Join();
while((NormalThread.ThreadState==System.Threading.ThreadState.Running) ||
(BulkThread.ThreadState==System.Threading.ThreadState.Running) ||
(SpecialThread.ThreadState==System.Threading.ThreadState.Running)
)
{
}
}
But most of time one or two threads are going to aborted or something happen and I loose their results.Sometimes this worked properly and I can get all results from 3 methods.
Can any one correct this code?
|
|
|
|
|
Repost. Though I'd seen it before and yes, a week ago you posted the same code. A complete c+p actually. No-one helped you then, what makes you think they will now?
He who makes a beast out of himself gets rid of the pain of being a man
|
|
|
|
|
So what? He is trying again and may have better luck. Why didn't you just ignore his post?
|
|
|
|
|
Hello,
Why are you doing the "Join()"?
What do the Methods of the Threads do?
What are the results you are expecting and where do you get them from?
All the best,
Martin
|
|
|
|
|
hi,
thanks for reply.
I am joining 3 threads with Join() method. Then 3 threads can execute parallary.
There are 3 methods ,all are return same types of arrays.
|
|
|
|
|
Hi!
The whole while(... construct is superfluous.
You start 3 threads and then call Join() for each of them.
So the last Join() will return only when NormalThread has finished and the other two threads have finished as well.
Depending on how you access the thread's "results", declaring the respective members as volatile might help.
Regards,
mav
--
Black holes are the places where God divided by 0...
|
|
|
|
|
I suggest using 3 AutoResetEvent that each thread would Set() when done. So, you start your three thread, and then, in your main thread, do a WaitHandle.WaitAll(....). It would be advised to use the overload with a timeout.
Your code could look something like this:
public MyClass
{
private AutoResetEvent _specialEvent = new AutoResetEvent();
private AutoResetEvent _normalEvent = new AutoResetEvent();
private AutoResetEvent _bulkEvent = new AutoResetEvent();
public threadtest()
{
Thread SpecialThread = new Thread(new ThreadStart(this.GetSpecial));
Thread BulkThread = new Thread(new ThreadStart(this.GetBulk));
Thread NormalThread = new Thread(new ThreadStart(this.GetNormal));
SpecialThread.Start();
BulkThread.Start();
NormalThread.Start();
WaitHandle.WaitAll(new WaitHandle[] { this._specialEvent, this._normalEvent, this._bulkEvent } );
}
public GetNormal()
{
this._normalEvent.Set();
}
public GetSpecial()
{
this._specialEvent.Set();
}
public GetBulk()
{
this._bulkEvent.Set();
}
}
You could consider using the BackgroundWorker class also.
|
|
|
|
|
Hi,
thanks a lot for reply. I will check with your codes and comeback soon.
Is there a problem ,when I am using Join() method?.
I need to run my 3 methods paralaly. all the 3 methods return same type of arrays.
|
|
|
|
|
Hi,
we have a requirement that we have to suppress/deactivate all other applications except one application(running). Can we accomplish this using C# or VB.net? could you please help me to finish this task?
For example, if we open one application, all other applications should be suppressed/deactivated. (means we should give access for only one application for the users).
Thanks in Advance
SMARTech
|
|
|
|
|
The practical answer is no. There are too many processes in the system that are required to keep your application aloft for a start.
You could, for example, attempt to increase the priority of your application above all others but this would have a detrimental effect. Again, because your application relies on parts of the operating system doing its job it won't help if the OS cannot do its job because your application is elevated above it.
I am, however, extremely suspicious of why you might want to prevent other applications running in the OS while your application is running. It sounds like something a virus or trojan would want to do.
|
|
|
|
|
Colin Angus Mackay,
Thanks for you quick response, I dont want to prevent the services of OS, I just dont want to give access to the user for other applications except the one. how to prevent the user to access all other applications except the one application (running)? could you please help in this issue?
Thanks
SMARTech
|
|
|
|
|
You can't do it from your code. This is something that's done using Group Policy in Windows. You can specify a list of applications that the user, or group of users, is allowed to run. THis is NOT something you can just turn on and off only when your application runs.
For further information, pickup the Windows XP or Windows 2003 Resource Kit. Group Policy is explained in there, taking up about half the book.
|
|
|
|
|
That sounds extremely user-hostile; don't expect anyone to want to use your application.
|
|
|
|
|
Hello,
My intention is not to force the user to use my application, but to give the access for only one application. Except that, the user could not open other applications on the system.
Thanks,
SMARTech
|
|
|
|
|
shah_tech wrote: My intention is not to force the user to use my application, but to give the access for only one application. Except that, the user could not open other applications on the system.
So forcing the user to user your application once it's running, even if it's only to turn the damn thing off. Sorry, but this sounds like malware - you are running totally contra to what a multitasking system should do. You still haven't explained why you would WANT to write an application that did this? Why do you want to alienate users?
|
|
|
|
|
So they can't even check their email while using it?
They can't lock the system for a potty break?
They would have to exit your app to do something else for a moment and then get back in?
If it hangs they can't get to the Task Manager to kill it?
|
|
|
|
|
yes, they should not be allowed for other applications while running my application, Can you please help?
|
|
|
|
|
I wouldn't even if I could. No one would want to use such a system. I certainly wouldn't, would you?
|
|
|
|
|
I created a MDI form & its child,
On child form I am doing database interaction and loading
the datatable object with table name "table1".
after doing all this when i run the MDI form & open up the child from,
its giving the following error:
"Cannot create a child list for the field table1"
Will anyone tells me the reason, or how to rectify this?
Thanks & regards to all.
|
|
|
|
|
|
Here somthing more if u can help?
When i try developing the same application using the VS designer its working fine, I created the MDI form, on its child form thru connection wizard i created the connection, dataadapter, dataset.
And write the correponding code for manipulating the data on child form,
everything working fine.
But when i am doing this thru coding, error is generating which i had mention earlier.
What i am doing is:
-> created a seprate class, on this creating the DB connectivity,
-> create the commandBuilder object, and the GetUpdateCommand, GetUpdateDelete, GetUpdateInsert.
-> filling the datatable object, returning it to child form class file.
on child class file performing the function.
Also when i compare the VS designer code & my code, some lines i am unable to understand like:
((System.ComponentMode1.IsupportIntialize)(this.dsComp)).BeginInit();
((System.ComponentMode1.IsupportIntialize)(this.dsComp)).EndInit();
And also i want to know what is difference when we creating DB connection thru wizard & connection thru coding?
which method one should use?
|
|
|
|