Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 years ago.
Improve this question
In my WPF application, I have to show some windows on UI thread and some on separate thread. I can access all windows running on UI thread using System.Windows.Application.Current.Windows, but unable to find windows that are running on separate thread.
Can any one knows how can i achieve this ?
Thanks
System.Windows.Application.Current.Windows only gives you Windows that where created on the UIThread not on WorkerThread. From the MSDN:
A Window reference is automatically added to Windows as soon as a window is instantiated on the user interface (UI) thread; windows that are created by worker threads are not added.
I guess you will have to do the book keeping on your own. For instance by using a static list of windows. Keep in mind that you need to guard that against concurrent access and you need to remove those windows when they get closed.
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I am developing a system that is based on WPF.
the UI need to let user compi and process.
There is a function inside,Ability to perform user compilation
So I can't control the user if user need to import third party dll
I use a Thread to implement this function.
But now there is a problem, if the user calls the window inside the dll, the windows will freezes.
Main
int main()
{
Thread th = new Thread(thread);
th.Start();
}
void thread()
{
LoadLibrary("C:\\123\windows.dll");
StartTest(dll_windows);
}
DLL
public static dll_windows()
{
ShowWindow();
}
In most, if not all frameworks I have seen across many languages, UI elements must be created on the UI thread. Creating them from another thread will lead to all kinds of problems.
Although you did not say what framework you use, I'm willing to bet it also goes for your framework. All your UI elements must be created from the UI thread.
Do work on the other thread, signal when it's done and then create the UI from the UI thread.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 4 years ago.
Improve this question
I am working on c# winforms.
after installing the application, if I keep the application open everyday without closing it,i want it to refresh data automatically.
I am using datetimepicker and getting data from files.
if the files are added into the folder it should be automatically update n keep running the application. Also wanted date to update everyday if application is open all the time.
Please help.
Use the timer control to achieve this. you can set interval time property.
if the files are added into the folder it should be automatically
update n keep running the application
For this use FileSystemWatcher Class.
Have you thought of writing a Windows Service which can run continuously and do all the update?This Windows app can just consume the Windows Service and whenever opened,will fetch the latest data.Simple!
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 5 years ago.
Improve this question
Any idea how to get all task bar items details in windows .I am looking for a notification if some thing new process came on task bar list
There is no official API to directly enumerate taskbar items, or query any details about them.
A Taskbar button is created for:
a visible top-level unowned window, or a visible window that has the WS_EX_APPWINDOW extended style. These windows can easily be discovered using an EnumWindows() callback that checks each available window using IsWindowVisible (), GetParent()/GetWindow(GW_OWNER), GetWindowLongPtr(GWL_EXSTYLE), etc.
a window that is added to the Taskbar manually using ITaskbarList::AddTab(). These windows cannot be enumerated. The only way I can think to discover them is to replace the standard CLSID_TaskbarList COM object with a custom DLL implementation that intercepts all ITaskbarList calls across all processes.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
Is it possible to somehow notify a running process from the "outside"?
I have a C# program that theoretical runs forever. And I would like to notify it to trigger some action manually. It would be best, if this solution is possible on Windows and Linux (mono).
EDIT:
The solution should work without a user interface
My program is, as for now, a part of web service. On initializing, a new Theread is created, which uses the Task class to stay alive
Take your forever-running-process and let it provide a webservice other processes can call.
You might use any cross-plattform webservice framework like WebApi or ServiceStack to achieve this via HTTP calls. This will even work over the internet (if the machines can reach each other).
There are dozens of approaches. You could also use named pipes for example, or put commands into a database (the other process has to query regularly) or - if you're fearless enough - write/read files to communicate. Be creative ...
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a program that loads data from a SharePoint site. It loads txt files, xml files, etc. Any of these "load" actions can take a lot of time because of the user's connectivity to the SharePoint. Therefore the whole windows form UI gets unresponsive until the data is loaded.
So I would like to know how can I easily create a thread for that "retrieval" of information while the whole windows forms UI still works and is operative.
You have a few options. I'm not going to provide exact code for any of them, but, I will provide you with research topics.
You can use a BackgroundWorker, Task.Run() or manage your own threading by doing Thread.Start(). Do you need to fire off an event when the downloading is finished? If so, you can do something like this:
var task = new Task(() => DoSomething());
task.ContinueWith(() => SignalDone(), TaskScheduler.FromCurrentSynchronizationContext());
task.Run();
The ContinueWith and TaskScheduler.FromCurrentSynchronizationContext will ensure that the signaling will be done on the UI thread to minimize race conditions. You're on your own if you're doing databinding to anything being populated.