|
Do they ?
But i tried one example and it didn't work fine on windows but works fine over console. I think their is a lil difference. May be not much but i need to know that difference. Ok ill look again over some console applications. Lets see if it works..
|
|
|
|
|
Hi James,
Only the thread a Form is created on can manipulate the form and it's child controls. Trying to set properties on controls from a worker process will throw an exception.
You would have to use the Invoke() method and send a delegate to the form that will be run on the controlling thread. Besides that they work pretty much the same.
T
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Yeh you are right. Just have a look in what i did. Its working but i want to know if there is any other better approach..
<br />
private void Startbtn_Click(Object sender, EventArgs e)<br />
{<br />
Thread t = new Thread(new ThreadStart(try));<br />
t.Start()<br />
}<br />
<br />
void try()<br />
{<br />
int count = 0;<br />
while (true)<br />
{<br />
if(count > 1000)<br />
{<br />
break;<br />
}<br />
Thread.Sleep(1000);<br />
if(InvokeRequired)<br />
Invoke(new new_try_delegate(new_try));<br />
count++;<br />
}<br />
}<br />
<br />
public delegate void new_try_delegate();<br />
<br />
void new_try()<br />
{<br />
textBox1.Text += "This is new Thread" + Environment.NewLine;<br />
}<br />
<br />
<br />
Now the above code just repeat the message "This is new Thread" for 1000 times and it works fine. But now my questions are:---
1.] Can i use same delegate call i.e. public delegate voud new_try_delegate() for all different threads i create.
And does it work the same way if i am writing data into textbox from different location of my application.
Lastly can you suggest me some more options to test so that i understand it better.
Cheers
|
|
|
|
|
I see some problems in your code.
1. What happens when you hit the start button a few times without waiting for the thread to finish.
2. Invoking the delegate from the thread does work from your thread, but this method requires that each object calling to the new_try() method know about the delegate and call that.
3. If the new_try() method is called from any other thread than the GUI thread, it will take time to execute the call.
The new_try() method should take the form of
public delegate void new_try_delegate();
new_try_delegate newTryEvent = new new_try_delegate(new_try);
public void new_try()
{
if (this.InvokeRequired)
{
Invoke.Begin( newTryEvent );
}
else
{
textBox1.Text += "This is new Thread" + Environment.NewLine;
}
}
Now you can call new_try() from any other thread and the GUI thread will do the work of displaying the string.
As for the first problem, you should always check to see if the thread is running before starting another instance of that thread so that the user doesn't run themselves out of resources.
Phil
|
|
|
|
|
That's a nice way of doing it. Didn't know about the InvokeRequired property.
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
okay... thanks for pointing that out.
|
|
|
|
|
Threads are mind bending to get your head round when you get into them. Took me ages to figure them out.
You already know a delegate is a function pointer, and as long as it isn't executed by a worker thread, and is instead processed by the Main thread, it will be thread safe and valid for UI manipulation. You can create as many instances of delegates pointing to the same function as you like, and simply run them on the main thread.
Try spawning multiple threads and firing off delegates for the same function with different fields. The invoke method lets you supply a parameter list after the delegate so you can supply arguments to the invoked function.
Also, you could experiment with.. i think it's Anonymous Methods, where you create the method body with the delegate declaration.
Good luck
T
-------------------------------
Carrier Bags - 21st Century Tumbleweed.
|
|
|
|
|
Hello friends,
can we get default program of file specified.
E.g. default program for .mp3 file may be windows media player/winamp like that.
Is there any method which gives such details of default program.
thanks in advance.
Rahul Kulkarni
|
|
|
|
|
You get that info via the registry, I don't know of a method that will look it up for you, however.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
|
I can't see that it does. The page you point to describes how the Default Programs API works, i.e. how to tell windows the capabilities of a certain application.
|
|
|
|
|
MyComputer\HKey_Classes_Root\AudioCD\Shell\Play\Command
Check it
Arun Kr
|
|
|
|
|
as I know it can be retrieved with shell32 FindExecutable API
but sometimes the results is not like what is Expected
Maybe this going to help
<code>
class Shell32Utils
{
const int FILENOASSOCIATED = 31;
const int FILENOTFOUND = 2;
const int PATHNOTFOUND = 3;
const int SUCCESS = 32;
const int BADFORMAT = 11;
[DllImport("shell32", EntryPoint = "FindExecutable")]
static extern int FindExecutable(string file, string directory, [MarshalAs(UnmanagedType.LPStr)] StringBuilder result);
public static string Find(string file)
{
string fileName=System.IO.Path.GetFileName(file);
string filePath = System.IO.Path.GetDirectoryName(file)+"\\";
System.Text.StringBuilder res = new StringBuilder(1024);
int stat = FindExecutable(fileName, filePath, res);
switch (stat)
{
case FILENOASSOCIATED: throw new Exception("File Not Associated");
case FILENOTFOUND: throw new Exception("FileNot Found");
case PATHNOTFOUND: throw new Exception("Path not Found");
case BADFORMAT: throw new Exception("Bad Format");
default: if (stat >= SUCCESS) return res.ToString();
else throw new Exception("Unknown Error");
}
}
}
</code>
good luck
|
|
|
|
|
Thank you very much.
It works fine
Rahul Kulkarni
|
|
|
|
|
Hi,
I'm getting an "object reference not set to an instance of an object" message in an exception generated while trying to assign a value to a cell in a DataTable. This assignment is happening within an event fired from the Grid that is used to display this table. What puzzles me is that there are no nulls in the assignment opeartion that is being done, and secondly the exception appears to originate from somewhere deep inside the code for the DataTable object.
The call at which the exception occurs according to the stack trace is
at System.Data.NameNode.Eval(DataRow row, DataRowVersion version)
Any pointers as to what might be causing this would be most appreciated.
Please let me know if you want the full stack trace (I didn't want to fill up all the space here with it).
Many thanks in advance.
Vishnu
|
|
|
|
|
Check do you have any of the column name having "." Charactor.
Regards
Elayaraja.S
|
|
|
|
|
Nope, no dots in any column name.
The first time I bind the table to the UI grid everything works fine. However after the datasource is bound to the grid a second time (for refreshing the result set), it starts behaving this way.
|
|
|
|
|
Found the problem
One of the columns was being removed and added again in a previous step before the event was triggered. Skipping this step seems to solve the problem. What I still don't understand is why the datatable should throw an exception when the schema is essentially unchanged.
I'll post an update when I find out, if anyone knows why please do let me know.
Thanks and regards,
Vishnu
|
|
|
|
|
Hello Every body,
I had generated an report but i m facing an problem in detail section.
In detail section I had four fields
1) category name
2) Category description(are not Mandatory)
3) sub category Name
4) sub category description (are not Mandatory)
But when the report is generated if their is no category description then it leaves that space and I want that next i.e. sub category name should come at that space not the blank space.
ex if description is their the output should be like dis:
Category1
this category belongs to birds.
subCategoryName
Sub category description .....
IF their is no category description then output should be:
Category1
subCategoryName
Sub category description .....
BUT IT SHOWING LIKE DIS:
Category1
subCategoryName
Sub category description .....
(working on c# 2005 windows application)
Regards,
rahul saini
|
|
|
|
|
Hi,
If you want resize the row depending the values in crystal report, you can have multiple detail section instead of single detail section.
there is some property in each section , suppress the section for empty block.
also explicity you can write your own function against the suppress property of section.
Regards
Elayaraja.S
|
|
|
|
|
Dear all,
I have made one application to check digital certificate against Revocation.
but it is throughing an error like : "The revocation function was unable to check revocation because the revocation server was offline.\r\n"
This is the code i have made up,
X509Store store = new X509Store("MY", StoreLocation.CurrentUser);
store.Open(OpenFlags.OpenExistingOnly | OpenFlags.ReadWrite);
//Output store information.
Console.WriteLine("Store Information");
Console.WriteLine("Number of certificates in the store: {0}", store.Certificates.Count);
Console.WriteLine("Store location: {0}", store.Location);
Console.WriteLine("Store name: {0} {1}", store.Name, Environment.NewLine);
//Put certificates from the store into a collection so user can select one.
X509Certificate2Collection fcollection = (X509Certificate2Collection)store.Certificates;
X509Certificate2Collection collection = X509Certificate2UI.SelectFromCollection(fcollection, "Select an X509 Certificate", "Choose a certificate to examine.", X509SelectionFlag.SingleSelection);
X509Certificate2 certificate = collection[0];
//X509Certificate2UI.DisplayCertificate(certificate);
//Output chain information of the selected certificate.
X509Chain chain = new X509Chain();
Oid oid = new Oid("2.5.29.31");
chain.ChainPolicy.ApplicationPolicy.Add(oid);
chain.ChainPolicy.CertificatePolicy.Add(oid);
chain.ChainPolicy.RevocationFlag = X509RevocationFlag.ExcludeRoot;
chain.ChainPolicy.RevocationMode = X509RevocationMode.Offline;
chain.ChainPolicy.UrlRetrievalTimeout = new TimeSpan(1000);
chain.ChainPolicy.VerificationFlags = X509VerificationFlags.AllFlags;
chain.Build(certificate);
if (chain.ChainStatus.Length != 0)
Console.WriteLine(chain.ChainStatus[0].Status);
Console.Read();
store.Close();
Please Help me if any one know its solution
Thanks and Regards,
Nitin Khubani
|
|
|
|
|
You need to provide more information than this, such as where the authority is.
Try running PKVIEW to see how healthy your PKI is. This tool can be located at here[^] (it's part of the Windows 2003 resource kit).
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Hi all!!,
how i can to set the TransparencyKey of a MDI child form ? , i' ve tried but it does not work:
<br />
this.TransparencyKey = Color.Magenta;<br />
this.BackColor = Color.Magenta;<br />
but the background is magenta and not transparent, how i can have the background transparent? thanks
Bye
|
|
|
|
|
Hello,
The Doku[^] gives only the information, that it is not supported when "RightToLeftLayout" is set to 'true'.
I think it could also be, that your graphic card doesn't support this feature (had it once, and it's also documented at msdn).
I think it had something todo with the "Color quality" in your "Display Properties" settings.
Maybe you can try to set it to "16Bit" instead of "32Bit"!
All the best,
Martin
|
|
|
|