FAQ Database Discussion Community


powershell invoke-restmethod environmental variable in url

rest,powershell,scripting,invoke
I am trying to make a very simple script that can delete a folder using Invoke-Restmethod. It works fine if I write the exact folder destination, but if I want to add stuff like $env:computername it simply returns empty Invoke-RestMethod -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)} -Uri http://rm44:8081/conf.fapi-1.4.0/client/machine/$env:computername/ -Method DELETE This...

C# SetPropertyThreadSafe vs Invoke thread-safe calls

c#,.net,multithreading,backgroundworker,invoke
Which of these two methods are better to update the UI from another thread? (for me they work both, but which is safer?) I would prefer the SetPropertyThreadSafe method as it needs less code. 1. label1.SetPropertyThreadSafe(() => this.label1.Text, "New Value"); 2. if (label1.InvokeRequired) { label1.Invoke(new MethodInvoker(delegate { label1.Text="New Value"; }));...

Use separate subs without invoking proporties

.net,vb.net,multithreading,thread-safety,invoke
I am trying to achieve a linear code without any "background workers" running alongside my main program (with the exception of a few System.Windows.Forms.Timers). I'm using Private Subs in order to eliminate the need to copy and paste, for example, the same 50 lines of code 10 times in my...

occasionally problems with invokerequired in c#

c#,winforms,invoke
I'm having problems with the invokerequired method from time to time and wanted to aks if someone knows that problem or can it explain to me. I have some code: splashScreen splashObj = splashScreen.GetInstance(); if (thrd == null) { thrd = new Thread(new ThreadStart(loadingScreenStart)); thrd.IsBackground = true; thrd.Start(); } else...

String to method (invoke) throws an Exception

java,string,invoke
I want to call a method, given a String. I mean, I have a String which is the name of the method I want to call. I've seen that the reflection is the way to meet the target but, when I try to get the method (before invoking it), I...

Invoking a custom Timer Class

xcode,function,swift,nstimer,invoke
I've cobbled together a Timer class to use NSTimer with all my ViewControllers, the code is below import Foundation class Timer { var timer = NSTimer() var handler: (Int) -> () let duration: Int var elapsedTime: Int = 0 init(duration: Int, handler: (Int) -> ()) { self.duration = duration self.handler...

Implement responsive gui with sleep without backgroundworker

c#,multithreading,user-interface,backgroundworker,invoke
I have this code, which holds a Sleep. Gui doesn't response well, although Invoke. When I did it with backgroundWorker, then the Gui responses well. Can this be done only with backgroundWorker? and if so, then why. Thank you. private void button1_Click(object sender, EventArgs e) { ThreadPool.QueueUserWorkItem((_) => F()); }...

Invoke form showdialog is not modal

vb.net,multithreading,invoke
I have 2 forms, 1 MainForm and 1 Form2. I am trying to display Form2 as a modal form and background from MainForm. Here's what I have so far. The default MainForm appears and after 5 seconds it will show Form2 as a Modal form from a background thread. I...

Whether program is executed from command line or invoked through system call

linux,command-line,executable,invoke,system-calls
Platform is linux and the c code is compiled in gcc. Is it possible to know from inside the code of program whether its executable has been executed directly from command line or invoked through "system" call ? e.g test.exe can be directly run on command line as ./test.exe or...

Closing Form from inside an Invoke

c#,winforms,exception,invoke,ui-thread
Closing a form from inside an Invoke like this: Invoke(new Action(() => { Close(); MessageBox.Show("closed in invoke from another thread"); new Form1(); })); throws an exception as soon as the form is closed: Invoke or BeginInvoke cannot be called on a control until the window handle has been created. But...

What is the Object paramter in MethodInfo.Invoke() for?

c#,reflection,invoke,methodinfo
What is the purpose of the Object obj parameter of MethodInfo.Invoke()? The MSDN documentation says: The object on which to invoke the method or constructor I don't understand how you invoke a method "on" an object. I thought you just called a method from Main() or a class and that's...

Python Invoke and console output issue

python,invoke
I am using Invoke for task execution. The problem is, it hides most of the console output. Because of which I cannot see output from my app. I have a task that runs a shell. Invoke changes the behavior of default shell. Back key does not work. What can I...

C# BackgroundWorker and Invoke

c#,.net,multithreading,backgroundworker,invoke
Can someone explain why invoking Thread.Sleep from BackgroundWorker blocks its execution. Invoke should cause the delegate to be executed on the UI thread and background thread should continue with execution. But that does not happen - why? public partial class Form1 : Form { public Form1() { InitializeComponent(); BackgroundWorker bgrw...

Calling a method with optional parameters from a string

c#,.net,methods,invoke,optional-parameters
I have multiple methods, some with optional parameters and some without any. How can i call those methods by only having the function name as a string? Currently i have this: public Method method = Method.QuickSort; public enum Method { BubbleSort, MergeSort, QuickSort, InsertionSort, RadixSortLSD, CocktailSort, CombSort, OddEvenSort } MethodInfo...

Cannot invoke function in my main ViewController from subclass in Swift

swift,invoke,func
I've created a method call in my main ViewController called processLogin. The actual process is done in another class from GetRemoteData.swift as below public class GetRemoteData { class func getValidationFromServer(success: ((svrData: NSData!) -> Void)) { . . ViewController.processLogin() } The line which tries to invoke processLogin which is set out...

How do invoke an already existing jquery function on an html anchor?

javascript,jquery,html,anchor,invoke
I created expandable content using jquery on several divs with unique ids. The code is working but now I also want to trigger this function from a top navigation using an anchor. I have tried several things but nothing works. I am very new to jquery so any help would...

In threading program when do you use Invoke?

c#,multithreading,invoke
Example code: private void button1_Click(object sender, EventArgs e) { Thread r= new Thread(new ThreadStart(DoWork)); r.Start(); } private void DoWork() { MessageBox.Show("test"); Thread.Sleep(2000); } When would a developer replace the MessageBox code with: this.Invoke(new Action(() => { MessageBox.Show(this, "test"); })); ...

Invoke a custom method on a DOM element

javascript,jquery,dom,methods,invoke
I want to invoke a custom method on a DOM element like this : <div id="MyObject"> <!-- some elements --> </div> <script> function doSomething() { // do something with input DOM element } $("MyObject").doSomething(); </script> How can I develop this problem? Is it necessary to use jQuery or not?...