Skip to main content

Posts

C# - Process.Start a ClickOnce application

string publisher_name = "ABCPublisher"; string product_name = "FaxManFMFFileCreator"; var shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\\",publisher_name, "\\", product_name, ".appref-ms"); Process.Start(shortcutName);

C# kill specific process

//Threading for speacific printer otherwise it will open default Faxman printer Task.Factory.StartNew(() => { Thread.Sleep(5000); // Killing Process of default printer Process[] processes = Process.GetProcessesByName("FaxManFMFFileCreator"); foreach (var process in processes) { process.Kill(); } });

The calling thread must be STA, because many UI components require this.

Using Thread: // Create a thread Thread newWindowThread = new Thread(new ThreadStart(() => { // You can use your code // Create and show the Window FaxImageLoad obj = new FaxImageLoad(destination); obj.Show(); // Start the Dispatcher Processing System.Windows.Threading.Dispatcher.Run(); })); // Set the apartment state newWindowThread.SetApartmentState(ApartmentState.STA); // Make the thread a background thread newWindowThread.IsBackground = true; // Start the thread newWindowThread.Start(); Using Task and Thread: // Creating Task Pool, Each task will work asyn and as an indivisual thread component Task[] tasks = new Task[3]; // Control drug data disc UI load optimize tasks[0] = Task.Run(() => { //This will handle the ui thread :The calling thread must be STA, because many U...

devexpress wpf gridcontrol disable context menu

If you want to disable any context menu item in devexpress grid like this. In XAML <dxg:GridControl x:Name="grdProfile" Width="1070" Height="400" HorizontalAlignment="Left" VerticalAlignment="Top" AutoGenerateColumns="None" ItemsSource="{Binding CusHisViewRefillHistoryList}" SelectedItem="{Binding SelectedCusHisViewRefillHistory}"> <dxg:GridControl.Columns> <dxg:GridColumn Width="100" Binding="{Binding RxNo}" Header="Rx #" /> <dxg:GridColumn Width="70" Binding="{Binding PhInitials}" Header="Ph. Initials" /> ...