Thanks! I just back from a business trip. I have googled the lambda operator specifies and research it.There are some differences in syntax. In .net 2.0, it need use delegate to define a virtual method instead of the lambda expressions. "it can not run", I said, means that, I could not debug the code in .net 2.0. And I just want to konw why it was happened. Thank you.
wjp_auhtm
Posts
-
a problem about "bool Exists(Predicate<T> match);" -
a problem about "bool Exists(Predicate<T> match);"Yes, I can. I just want to konw why I could not debug the code successed in .net 2.0.
-
a problem about "bool Exists(Predicate<T> match);"Thanks! I have googled the lambda operator specifies and research it.There are some differences in syntax. In .net 2.0, it need use delegate to define a virtual method instead of the lambda expressions. Thank you.
-
a problem about "bool Exists(Predicate<T> match);"Thanks! I just back from a business trip. I have googled the lambda operator specifies and research it.There are some differences in syntax. In .net 2.0, it need use delegate to define a virtual method instead of the lambda expressions. Thank you.
-
a problem about "bool Exists(Predicate<T> match);"Thanks! There is another problem. The parameter "b" whose type as same as parameter "item" is not defined. And the parameter "b" have not defined anywhere. I try to change the name of parameter "b" to "a",it also could run. I am puzzled about this.
-
a problem about "bool Exists(Predicate<T> match);"I am trying to convert some code to .net framework 2.0 from .net framework 3.0. the code of .net framework 3.5 is:
if (mItems.Exists(b => string.Compare(b.FileName, item.FileName, StringComparison.OrdinalIgnoreCase) == 0))
return;It can run in .net framework 3.5 and can not run in .net framework 2.0. Could someone tell me where the defferent things between 3.5 from 2.0 in the code are.
-
windows not in focusI.C. But, just remind once. I know little about the Logging, I will have some research about that.
-
windows not in focusThe function "IsRunning" will check if the windows service is running. I think that when creating a windows service just like creating a application, so I do not know how to create it programatically. We must set the windows service before we release it.
-
windows not in focusOK, the simple code to check if the service is running like this.
/// <summary> /// TODO: Is the windows service running. /// </summary> /// <param name="name">The name of windows service.</param> private bool IsRunning(string name) { bool IsRun = false; if (!isServiceIsExisted(name)) // this function was named previously. { return false; } ServiceController sc = new ServiceController(name); if (sc.Status == ServiceControllerStatus.StartPending || sc.Status == ServiceControllerStatus.Running) { IsRun = true; } sc.Close(); return IsRun; }
Set the service to start automatically: Change the value of property named "StartType" of the windows service to "Automatic". BTW, owing to the limitation of my knowledge, the code are not very strong.I suggest that you can research them by yourself. I think that after you reserach them, you will learn more.
-
windows not in focusIf set the windows service autorun, when you restart computer, the service will start. Of course, you can start the service in manual like this.
/// <summary> /// TODO: Start windows service. /// </summary> /// <param name="name">The name of windows service.</param> /// <returns>If success return true,or return false.;</returns> private bool StarmyService(string name) { ServiceController sc = new ServiceController(name); if (sc.Status == ServiceControllerStatus.Stopped || sc.Status == ServiceControllerStatus.StopPending ) { sc.Start(); sc.WaitForStatus(ServiceControllerStatus.Running, new TimeSpan(0, 0, 10)); } else { } sc.Close(); return true; }
And stop the service like this
/// <summary> /// TODO: Stop windows service. /// </summary> /// <param name="name">The name of windows service.</param> /// <returns>If success return true,or return false.;</returns> private bool StopmyService(string name) { ServiceController sc = new ServiceController(name); if (sc.Status == ServiceControllerStatus.Running || sc.Status == ServiceControllerStatus.StartPending) { sc.Stop(); sc.WaitForStatus(ServiceControllerStatus.Stopped, new TimeSpan(0, 0, 10)); } else { } sc.Close(); return true; }
-
windows not in focusYou could install the windows service like this, if u are using .Net FrameWork 3.5. I found that the file named "System.Configuration.Install.dll" in .Net 2.0 is different from the .Net 3.5's. There are some simple code.
using System.ServiceProcess;
using System.Configuration.Install;
using System.Collections;/// <summary> /// TODO: Is the service is existed and return true or false. /// </summary> /// <param name=" NameService ">Name of the windows service.</param> /// <returns>If the service is existed then return true,or return false.</returns> private bool isServiceIsExisted(string NameService) { ServiceController\[\] services = ServiceController.GetServices(); foreach (ServiceController s in services) { if (s.ServiceName.ToLower() == NameService.ToLower()) { return true; } } return false; } /// <summary> /// TODO: Install windows service. /// </summary> /// <param name="stateSaver">Collection(default is Null)</param> /// <param name="filepath">Full path of the windows service file</param> private void InstallmyService(IDictionary stateSaver, string filepath) { AssemblyInstaller AssemblyInstaller1 = new AssemblyInstaller(); AssemblyInstaller1.UseNewContext = true; AssemblyInstaller1.Path = filepath; AssemblyInstaller1.Install(stateSaver); AssemblyInstaller1.Commit(stateSaver); AssemblyInstaller1.Dispose(); } /// <summary> /// TODO: Uninstall windows service. /// </summary> /// <param name="filepath">Full path of the windows service file</param> private void UnInstallmyService(string filepath) { AssemblyInstaller AssemblyInstaller1 = new AssemblyInstaller(); AssemblyInstaller1.UseNewContext = true; AssemblyInstaller1.Path = filepath; AssemblyInstaller1.Uninstall(null); AssemblyInstaller1.Dispose(); }
Good Luck!
-
windows not in focusYes, it can not instantiation a win form and show it. But I think that the socket could connect the win service and win app.
-
windows not in focus -
windows not in focusI think that you need create a windows service. When the computer got data, the service app show the data on the form's textbox, even the form unfocused.
-
MultiThread and File processYou can instantiate the class to a variable. Then use the variable which instantiated to open each files. I just write a simple example for you. And, this is only a guiding idea. I consider that the more problems solved by oneself the more he/she learned. There was an old sentence, in our country, said that,"Teaching someone fishing than giving he/she fishes." I suggest that trying each one's answer and google it,I think you will learn more by yourself. I am sorry for my poor English. Good Luck!
-
MultiThread and File processHi: I just write a simple example for you. I hope it was useful for you.
/// <summary> /// example of MultiThread /// </summary> class MultiThread { Thread td_example = null; System.Windows.Forms.Control _ctl; public MultiThread(System.Windows.Forms.Control ctl) { td_example = new Thread(new ThreadStart(CalledMethod)); _ctl = ctl; } /// <summary> /// start the thread /// </summary> public void startThread() { td_example.Start(); } /// <summary> /// pause the thread /// </summary> public void suspendThread() { td_example.Suspend(); } /// <summary> /// stop the thread /// Don't forget release the thread by this method /// sometimes, the thread willn't exit and still run after the form closed /// so, I suggest that to call this method before you want to close the main form. /// </summary> public void abortThread() { td_example.Abort(); } int i = 0; private void CalledMethod() { // // TODO:write your code here. // while (true) { i++; System.Windows.Forms.MessageBox.Show(i.ToString()); Thread.Sleep(1000); } } }
good luck! -
Chinese And English:)
-
how to disable close button of windows formyou can do it like this
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
but, you need to write methods such as 'MovingForm'or 'ResizeForm' or something else by yourself.
-
Chinese And English你好 NightJammer: Nice to meet you!It is true that there are many wise and knowledged people here.Past few days,Beijing was not very hot.Since some rains,the weather is more and more cold. 祝好运! :)
-
Chinese And EnglishHi everybody: I come from China and learning English ,if somebody whose mother Language is English and want to learn Chinese,we can learn from each other. I also a .Net developer on c#. My msn:wjp_auhtm@hotmail.com Thanks! :) wjp_auhtm 9/01