Control.Invoke cannot be reached
I am working in a .NET Framework + DevExpress project that uses GridControl
/ GridView
and I faced the following problem.
In many background threads we prepare data, that should be updated in GridView
. When data is ready for update, it is being pushed from a background thread to the UI Thread with Control.Invoke
.
Unluckily, some of the attempts to call Control.Invoke
fail. That means that the background thread waits for Control.Invoke
forever and it cannot be reached.
It's worth to add that UI is all the time responsive. Moreover UI thread switches to idle mode, when all task are done (apart from invoking that waiting background thread). The error occurs relatively seldom (in average once a week).
Any ideas what can cause such an issue?
See also questions close to this topic
-
The problem with setting up IIS UrlRewrite rules for ASP.NET Core 3.1 after migration
I am trying to do a migration for the ASP.NET Core Web Application from 2.2 to 3.1. The frontend app for the application is
Angular
. This is the workingasp.net core 2.2
piece of code fromStartup.cs
:public void Configure(IApplicationBuilder app, IHostingEnvironment env) { //... app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseAuthentication(); ConfigureUrlRewriting(app, env); ConfigureRouting(app); } private static void ConfigureUrlRewriting(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment() && File.Exists("IISUrlRewrite.xml")) { using (var reader = File.OpenText("IISUrlRewrite.xml")) { var options = new RewriteOptions().AddIISUrlRewrite(reader); app.UseRewriter(options); } } } private static void ConfigureRouting(IApplicationBuilder app) { app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new List<string> { "index.html" } }); app.UseStaticFiles(); app.UseMvc(routes => { routes.MapRoute(name: "default", template: "api/{controller}/{id}"); }); }
After migration to asp.net core 3.1 following the guide from Microsoft docs the code changed like:
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { //... app.UseCors(x => x.AllowAnyOrigin().AllowAnyMethod().AllowAnyHeader()); app.UseAuthentication(); ConfigureUrlRewriting(app, env); ConfigureRouting(app); } private static void ConfigureUrlRewriting(IApplicationBuilder app, IHostEnvironment env) { if (env.IsDevelopment() && File.Exists("IISUrlRewrite.xml")) { using (var reader = File.OpenText("IISUrlRewrite.xml")) { var options = new RewriteOptions().AddIISUrlRewrite(reader); app.UseRewriter(options); } } } private static void ConfigureRouting(IApplicationBuilder app) { app.UseDefaultFiles(new DefaultFilesOptions { DefaultFileNames = new List<string> { "index.html" } }); app.UseStaticFiles(); // Changed only the lines below app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapControllerRoute(name: "default", pattern: "api/{controller}/{id}"); }); }
After deploying on IIS local server there is the problem that all requests for static files returns
index.html
Here's the proof:Here's the content of
IISUrlRewrite.xml
:<rewrite> <rules> <rule name="AngularJS Routes" stopProcessing="true"> <match url=".*" /> <conditions logicalGrouping="MatchAll"> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" /> <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" /> <add input="{REQUEST_URI}" pattern="^/(api)/" negate="true" /> </conditions> <action type="Rewrite" url="/" /> </rule> </rules> </rewrite>
Seems like the condition
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
is not matched for the static files. But the condition is mathed when the app isasp.net core 2.2
Can someone explain please this behaviour after migration? Is it the problem of
.net core
code or IIS-side problems? -
Error, platform-specific implementation not set // AdColony Unity
I was Trying to implement Adcolony into my unity project and this error has appeared. I hope someone can help me. The variables are:
string[] zoneIds = new string[] { "vz150fd4742f8f4281a1", "vz3bea056c072d437287" }; string APP_ID = "appbdca0d68df44424f90"; AdColony.AppOptions options = new AdColony.AppOptions();
My Start() function is :
private void Start() { Debug.Log(APP_ID); Debug.Log(zoneIds[0]+" "+zoneIds[1]); if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) { AdColony.Ads.Configure(APP_ID, null, zoneIds); } }
My OnMouseDown() function is :
public void OnMouseDown() { AdColony.AdOptions adOptions = new AdColony.AdOptions(); adOptions.ShowPrePopup = false; adOptions.ShowPostPopup = false; AdColony.Ads.RequestInterstitialAd(zoneIds[0], adOptions); AdColony.Ads.OnRequestInterstitial += (AdColony.InterstitialAd ad) => { StartCoroutine(addAds()); gameObject.GetComponent<Collider2D>().enabled = true; gameObject.GetComponent<Animator>().enabled = true; todayEarnings.enabled = true; totalEarnings.enabled = true; Destroy(Loading); }; AdColony.Ads.OnExpiring += (AdColony.InterstitialAd ad) => { AdColony.Ads.RequestInterstitialAd(ad.ZoneId, adOptions); }; AdColony.Ads.OnRewardGranted += (string zoneId, bool success, string name, int amount) => { SceneManager.LoadScene("playScene1"); }; AdColony.Ads.OnRequestInterstitialFailed += () => { SceneManager.LoadScene("playScene1"); }; AdColony.Ads.OnOpened += (AdColony.InterstitialAd ad) => { StartCoroutine(addAds()); gameObject.GetComponent<Collider2D>().enabled = true; gameObject.GetComponent<Animator>().enabled = true; todayEarnings.enabled = true; totalEarnings.enabled = true; Destroy(Loading); }; AdColony.Ads.OnClosed += (AdColony.InterstitialAd ad) => { SceneManager.LoadScene("playScene1"); }; }
The error is :
Error, platform-specific implementation not set UnityEngine.Debug:LogError(Object) AdColony.Ads:get_SharedInstance() (at Assets/AdColony/Scripts/AdColony.cs:299) AdColony.Ads:IsSupportedOnCurrentPlatform() (at Assets/AdColony/Scripts/AdColony.cs:308) AdColony.Ads:IsInitialized() (at Assets/AdColony/Scripts/AdColony.cs:317) AdColony.Ads:RequestInterstitialAd(String, AdOptions) (at Assets/AdColony/Scripts/AdColony.cs:53) gotoPlayScene:OnMouseDown() (at Assets/Scripts/homeScripts/gotoPlayScene.cs:83) UnityEngine.SendMouseEvents:DoSendMouseEvents(Int32)
-
Unload Event firing on Page Loading in Asp.net
I wanted to fire unload event when page is close or close browser tab / window. I have used below code but it is firing when page it load instead of page unload. I have used master / child page concept in asp.net
Partial Class test Inherits System.Web.UI.Page Dim dbconn As Object = New DBConnection() Private Sub test_Unload(sender As Object, e As EventArgs) Handles Me.Unload dbconn.OpenConnection() Dim cmd As SqlCommand = New SqlCommand("UPDATE test SET abc = '2' where sno = '123'", dbconn.con) cmd.CommandType = CommandType.Text cmd.ExecuteNonQuery() dbconn.CloseConnection() End Sub End Class
-
How to set Java HTTP Server context handler threaded safe?
I am trying make my own http server in Java.
The purpose of the application is to get RequestBody as json.
Parsing key and value to string seperately.Running application with codes down below and when I use curl to test.
I get this error. Do you have any ideas?curl http://127.0.0.1:33334 -d @test.json --header "Content-Type: application/json"
curl: (18) transfer closed with 32 bytes remaining to readMain.java
package com.server.entry.http; import com.fasterxml.jackson.databind.ObjectMapper; import com.server.functions.Init; import com.server.models.ProgramArgument; import com.sun.net.httpserver.HttpExchange; import com.sun.net.httpserver.HttpHandler; import com.sun.net.httpserver.HttpServer; import org.apache.log4j.Logger; import java.io.*; import java.net.InetSocketAddress; import java.util.*; import java.util.concurrent.Executors; public class Main { static Logger logger = Logger.getLogger(Main.class); public static void main(String[] args) throws Exception { Init init = new Init(); ProgramArgument programArgument = new ProgramArgument(); init.sortArg(programArgument, args); Properties p = init.readProperties(programArgument.getPropertiesPath()); init.configruProperties(p.getProperty("logPath")); String hostName = p.getProperty("hostName"); int port = Integer.parseInt(p.getProperty("port")); try { HttpServer server = HttpServer.create(new InetSocketAddress(hostName,port), 10); server.createContext("/", MyHandler.getInstance()); server.setExecutor(Executors.newCachedThreadPool()); server.start(); } catch (Exception e) { logger.error("{}", e); } } static class MyHandler implements HttpHandler { private MyHandler() {} public static MyHandler getInstance() { return LazyHolder.INSTANCE; } private static class LazyHolder { private static final MyHandler INSTANCE = new MyHandler(); } @Override public void handle(HttpExchange t) throws IOException { String response = "This is the response"; t.sendResponseHeaders(200, response.length()); ObjectMapper mapper = new ObjectMapper(); Map<String, Object> jsonMap = mapper.readValue(t.getRequestBody(), Map.class); Iterator<String> itr = jsonMap.keySet().iterator(); StringJoiner keyJoiner = new StringJoiner(",", "", ""); StringJoiner valueJoiner = new StringJoiner("','", "'", "'"); while(itr.hasNext()) { String key = itr.next(); keyJoiner.add(key); valueJoiner.add((String)jsonMap.get(key)); } System.out.println(keyJoiner.toString()); System.out.println(keyJoiner.toString()); OutputStream os = t.getResponseBody(); os.write(response.getBytes()); os.close(); } } }
test.json
{ "name": "dddddddddd", "email": "dddd@ddd.com", "age": 25 }
I want to get result like this.
key : name,email,age , value : 'dddddddddd','dddd@ddd.com','25'
Thank you guys.
-
How to optimize the counting of words and characters in a huge file using multithreading?
I have a very large text file around 1 GB having only one line.
I need to count the number of words and characters (non-space characters).
I have written the below code.
string fileName = "abc.txt"; long words = 0; long characters = 0; if (File.Exists(fileName)) { using (StreamReader sr = new StreamReader(fileName)) { string[] fields = null; string text = sr.ReadToEnd(); fields = text.Split(' ', StringSplitOptions.RemoveEmptyEntries); foreach (string str in fields) { characters += str.Length; } words += fields.LongLength; } Console.WriteLine("The word count is {0} and character count is {1}", words, characters); }
Is there any way to make it faster using threads, someone has suggested me to use threads so that it will be faster?
I have found one issue in my code that will fail if the numbers of words or characters are greater than the
long
max value.I have written this code assuming that there will be only English characters, but there can be non-English characters as well.
I am especially looking for the thread related suggestions.
-
After applying mutex lock, can we still achieve parallelism in multithreading?
I applied a mutex lock for the simultaneous execution of threads. Is there a way to achieve parallelism so that other threads don't have to wait for the first thread?
Here, I want to apply the lock function on a node, but we have to check if there's any descendant or any ancestor which is not locked already. If it's locked, we will return false and if is not locked, we will lock the current node and then increase the
noOfLockedDescendants
on each parent of ancestors.#include<bits/stdc++.h> #include <mutex> using namespace std; mutex mtx; class TreeNode{ public: vector<TreeNode*> children; bool isLocked; int noOfLockedDescendants; TreeNode* parent; TreeNode(vector<TreeNode*> children, TreeNode* root){ if(children.size()!=0){ for(auto node:children){ node->parent = this; } } this->children = children; this->parent = parent; this->isLocked = false; this->noOfLockedDescendants = 0; } bool lock(){ if(this->isLocked) return false; mtx.lock(); //mutex lock if(this->noOfLockedDescendants>0){ mtx.unlock(); return false; } TreeNode* ancestor = this->parent; while(!ancestor){ if(ancestor->isLocked){ mtx.unlock(); return false; } ancestor = ancestor->parent; } mtx.unlock(); //mutex unlock ancestor = this->parent; while(!ancestor){ ancestor->noOfLockedDescendants++; ancestor = ancestor->parent; } this->isLocked = True; return true; } void unlock(){ if(this->isLocked == false) return; TreeNode* ancestor = this->parent; while(!ancestor){ ancestor->noOfLockedDescendants--; ancestor = ancestor->parent; } this->isLocked = false; } };
-
Cannot import invoke-obfuscation module
I can't figure out how to import invoke-obfuscation. I've tried to set execution policies to unrestricted, but no luck. I run the import-module command, no error or complaints. I proceed to try to run the command, "invoke-obfuscation".
I then receive the following response before the window closes by itself:
If I try to run the command it suggests in that response, I still get the same error response.
If anyone can suggest any solutions to this problem, I'd appreciate it.
-
PropertyChanged doesn't work if property was updated from another process?
The problem is: I want my window change position if another window changes position. I have ran a function in another thread that checks another window position every 50 millisecond. All is working if I change myWindow.Left and myWindow.Top from another process directly like that:
Application.Current.Dispatcher.Invoke((System.Action)delegate{ this.Left = newTablePosition.Left + xShift; this.Top = newTablePosition.Top + yShift; });
But it doesn't work, if I try to bind my Window.Left to X and Window.Top to Y, and then change X and Y from another thread. I have implemented INotifyPropertyChanged:
public double X{ set{ x = value; OnPropertyChanged(nameof(X)); } get{return x;} } private double y; public double Y { set{ y = value; OnPropertyChanged(nameof(Y)); } get{return y;} }
But this code doesn't invoke my window move:
Application.Current.Dispatcher.Invoke((System.Action)delegate{ X = newTablePosition.Left + xShift + HUDPosition.x; Y = newTablePosition.Top + yShift + HUDPosition.y; })
I am calling this code in a such way:
Thread newthread = new Thread(CheckTablePosition){IsBackground = true}; isActive = true; newthread.Start();
And function:
public void CheckTablePosition(){ while (isActive){ Thread.Sleep(50); var newTablePosition = new TablePosition(_table.hWnd); if (_tablePosition.IsEqual(newTablePosition)){ continue; } _tablePosition = newTablePosition; var xShift = (int) (newTablePosition.Width * _defaultPosition.x); var yShift = (int) (newTablePosition.Height * _defaultPosition.y); try { Application.Current.Dispatcher.Invoke((System.Action)delegate{ this.Left = newTablePosition.Left + xShift + HUDPosition.x; this.Top = newTablePosition.Top + yShift + HUDPosition.y; OnPropertyChanged(nameof(Y));}); } catch(Exception ex) { MessageBox.Show(ex.ToString()); break; } } }
-
Invoke EntryPoint of assembly without showing any window - VB.Net
I need to execute an application embeeded in my resources . Heres my code :
Dim MainAssembly As Reflection.Assembly = Reflection.Assembly.GetExecutingAssembly() Dim resourceStream As Stream = MainAssembly.GetManifestResourceStream("MyApp.Nircmd.exe") If resourceStream Is Nothing Then Throw New NullReferenceException("error") End If Dim toolAssemblyBuffer(CInt(resourceStream.Length) - 1) As Byte resourceStream.Read(toolAssemblyBuffer, 0, toolAssemblyBuffer.Length) resourceStream.Close() AudioTool = Reflection.Assembly.Load(toolAssemblyBuffer) Dim args() As String = {Application.StartupPath, "argumentsHere"} Dim parameters = New Object() {args} Try AudioTool.EntryPoint.Invoke(Nothing, parameters) Catch End Try
This application opens a new cmd.exe window everytime , so , i need to invoke the EntryPoint without showing any window . Is there a WindowStyle property or something equal in an assembly ? Thanks
-
Strong name signature not valid for this assembly devexpress.data.v20.1.dll
I publish my application with Deploy method. But during installation popup error with log: "Strong name signature not valid for this assembly devexpress.data.v20.1.dll".
- I tried this method. [https://supportcenter.devexpress.com/ticket/details/t881415/strong-name-signature-not-valid-for-this-assembly-for-devexpress-data-v19-2-dll][1]
- I tried all tips from stackoverflow(ClickOnce). But I can not found solution. I have a one way: I can export only Release/Debug folder. Applications in this folder are working. Before, I deploy my application to shared folder, and when user run app, app update itself. Now I need manually update app of every user. How correctly deploy app with devexpress components.
-
Variants and Search in Devexpress XAF Ribbon Form
How to get variants in main ribbon as and drop down icon menu instead of the default dropdown list. also for the search, by default it will show up in the main ribbon not on the top right side as in the photo attached. the below image is from official Devexpress documentation here.
-
What is the best reporting service that can be used with node.js I'm currently using devexpress and it is not very good and causes a lot of problems?
The reporting service I'm using doesn't for example load url if it is in the format /utilities/download/img.jpg it has to be a full url and it doesn't load fat urls besides looping through the data is a nightmare.